iterative / shtab

↔️ Automagic shell tab completion for Python CLI applications
https://docs.iterative.ai/shtab
Other
375 stars 34 forks source link

shtab generates invalid shell output from Python files that have an explicit py extension #20

Closed mpkocher closed 4 years ago

mpkocher commented 4 years ago

Using shtab 1.3.0, the autocomplete output generated from python files with an explicit .py extension and/or with a '-' in the file name will create invalid code.

For example, using zsh and my_example.py will generate invalid code.

The code generated looks like this.

_shtab_my_example.py_options_=(
  "(- :)"{-h,--help}"[show this help message and exit]"
  "--input-file[Path to file]:input_file:"
  "--max-records[Max Records to process]:max_records:"
  "--alpha[Level of alpha filtering to apply]:alpha:"
  "--print-completion[print shell completion script]:print_completion:(bash zsh)"
)

Using my-example.py will generate similar issues.

Specifically, the error look similar to this:

./my_example2.py --hel...        
_my_example2.py:5: unknown file attribute: \n
_my_example2.py:5: unknown file attribute: \n
_my_example2.py:5: unknown file attribute: \n