Tqdm: CLI: Cannot escape hyphens in description

Created on 14 Feb 2018  Â·  4Comments  Â·  Source: tqdm/tqdm

$ seq 1000 | tqdm --total 1000 --desc 'test-test' > /dev/null

Error:
Usage:
  tqdm [--help | options]
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tqdm/_main.py", line 144, in main
    tqdm_args[o] = cast(v, opt_types[o])
KeyError: 'test'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/tqdm", line 11, in <module>
    load_entry_point('tqdm==4.19.5', 'console_scripts', 'tqdm')()
  File "/usr/lib/python3.6/site-packages/tqdm/_main.py", line 146, in main
    raise TqdmKeyError(str(e))
tqdm._tqdm.TqdmKeyError: "'test'"

vs:

$ seq 100 | tqdm --total 100 --desc 'test_test' > /dev/null # works fine

(Using 4.19.5 on linux.)

p2-bug-warning ⚠ submodule ⊂

All 4 comments

hah, nice bug - my hacky dependency-free parsing to blame.

@casperdcl why not use argparse?

There's something nice about being completely dependency-free (it's not built-in for python 2.6, and would require us to basically implement argopt (or docopt) for us to support docstring-derived CLI parameters. Anyway I just realised my devel branch commit perfectly solves this issue (tqdm --desc 'foo-bar' is fine, and tqdm --desc '-foobar' isn't, which is normal for CLI programs)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergeysprogis picture sergeysprogis  Â·  4Comments

yarikoptic picture yarikoptic  Â·  3Comments

schwobr picture schwobr  Â·  5Comments

phillies picture phillies  Â·  3Comments

andreasbaumann picture andreasbaumann  Â·  5Comments