Closed mgorny closed 9 months ago
Sorry about that... looks like something went wrong there. I created a cli command for easy commandline usage similar to pv
but I totally forgot to finish it. I'll remove the command for now and re-add it once it's fully working.
Facing the same issue, any update ?
I'm working on a command that can be used as a drop-in replacement for the pv
(pipeview) command with better output and some extra intelligence. A sneak preview of what it should roughly handle (if possible):
import argparse
import contextlib
import pathlib
import sys
import time
import progressbar
def create_pv_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description='Monitor the progress of data through a pipe.')
# Display switches
parser.add_argument('-p', '--progress', action='store_true',
help='Turn the progress bar on.')
parser.add_argument('-t', '--timer', action='store_true',
help='Turn the timer on.')
parser.add_argument('-e', '--eta', action='store_true',
help='Turn the ETA timer on.')
parser.add_argument('-I', '--fineta', action='store_true',
help='Display the ETA as local time of arrival.')
parser.add_argument('-r', '--rate', action='store_true',
help='Turn the rate counter on.')
parser.add_argument('-a', '--average-rate', action='store_true',
help='Turn the average rate counter on.')
parser.add_argument('-b', '--bytes', action='store_true',
help='Turn the total byte counter on.')
parser.add_argument('-8', '--bits', action='store_true',
help='Display total bits instead of bytes.')
parser.add_argument('-T', '--buffer-percent', action='store_true',
help='Turn on the transfer buffer percentage display.')
parser.add_argument('-A', '--last-written', type=int,
help='Show the last NUM bytes written.')
parser.add_argument('-F', '--format', type=str,
help='Use the format string FORMAT for output format.')
parser.add_argument('-n', '--numeric', action='store_true',
help='Numeric output.')
parser.add_argument('-q', '--quiet', action='store_true', help='No output.')
# Output modifiers
parser.add_argument('-W', '--wait', action='store_true',
help='Wait until the first byte has been transferred.')
parser.add_argument('-D', '--delay-start', type=float, help='Delay start.')
parser.add_argument('-s', '--size', type=str,
help='Assume total data size is SIZE.')
parser.add_argument('-l', '--line-mode', action='store_true',
help='Count lines instead of bytes.')
parser.add_argument('-0', '--null', action='store_true',
help='Count lines terminated with a zero byte.')
parser.add_argument('-i', '--interval', type=float,
help='Interval between updates.')
parser.add_argument('-m', '--average-rate-window', type=int,
help='Window for average rate calculation.')
parser.add_argument('-w', '--width', type=int,
help='Assume terminal is WIDTH characters wide.')
parser.add_argument('-H', '--height', type=int,
help='Assume terminal is HEIGHT rows high.')
parser.add_argument('-N', '--name', type=str,
help='Prefix output information with NAME.')
parser.add_argument('-f', '--force', action='store_true',
help='Force output.')
parser.add_argument('-c', '--cursor', action='store_true',
help='Use cursor positioning escape sequences.')
# Data transfer modifiers
parser.add_argument('-L', '--rate-limit', type=str,
help='Limit transfer to RATE bytes per second.')
parser.add_argument('-B', '--buffer-size', type=str,
help='Use transfer buffer size of BYTES.')
parser.add_argument('-C', '--no-splice', action='store_true',
help='Never use splice.')
parser.add_argument('-E', '--skip-errors', action='store_true',
help='Ignore read errors.')
parser.add_argument('-Z', '--error-skip-block', type=str,
help='Skip block size when ignoring errors.')
parser.add_argument('-S', '--stop-at-size', action='store_true',
help='Stop transferring after SIZE bytes.')
parser.add_argument('-Y', '--sync', action='store_true',
help='Synchronise buffer caches to disk after writes.')
parser.add_argument('-K', '--direct-io', action='store_true',
help='Set O_DIRECT flag on all inputs/outputs.')
parser.add_argument('-X', '--discard', action='store_true',
help='Discard input data instead of transferring it.')
parser.add_argument('-d', '--watchfd', type=str,
help='Watch file descriptor of process.')
parser.add_argument('-R', '--remote', type=int,
help='Remote control another running instance of pv.')
# General options
parser.add_argument('-P', '--pidfile', type=pathlib.Path,
help='Save process ID in FILE.')
parser.add_argument(
'input',
help='Input file path. Uses stdin if not specified.',
default='-',
nargs='*',
)
parser.add_argument(
'-o',
'--output',
default='-',
help='Output file path. Uses stdout if not specified.')
return parser
It won't be long, I promise :)
I've created a new release with a progressbar
command that can be used as a drop-in replacement for pv
or to replace cat
as an automatic progressbar.
It can be used like this:
progressbar /dev/zero > /dev/zero
Or like this:
cat /dev/zero | progressbar > /dev/zero
If the filesize is available it will show a progressbar, if not, it will show a spinner like the regular progressbar would
Description
progressbar2 4.3.0 installs a
cli-name
executable that refers to aprogressbar.cli
module that does not exist.Also, I'd advise against using such a generic name.
cli-name
doesn't really sound like something related toprogressbar
at all.Code
Versions
3.12.1 (main, Dec 8 2023, 13:15:10) [GCC 13.2.1 20231014]