multiversx / mx-sdk-py-cli

Python Command Line Tools and SDK for interacting with the MultiversX blockchain and dApps.
Other
35 stars 36 forks source link

Add shell completions #406

Closed popenta closed 5 months ago

popenta commented 5 months ago

mxpy is now capable of shell completions using argcomplete. Keep in mind that argcomplete works only for bash and zsh shells.

After installing mxpy using pipx the following line needs to be added to your shell file. For bash, add it in the .bashrc file.

eval "$(register-python-argcomplete mxpy)"

Then, open a new terminal and enjoy autocompletions. Press <Tab> for completions and <Tab><Tab> to see all the options. Don't forget that for a more detailed look the --help or -h arguments can be used.

For reference: https://stackoverflow.com/questions/14597466/custom-tab-completion-in-python-argparse/15289025#15289025 Another alternative was to use shtab.

popenta commented 5 months ago

Do people need to install argcomplete separately, so that register-python-argcomplete is available? Since pipx will only install it in a venv.

Is it possible to test this somehow in a github workflow (maybe not)?

No, they don't need to install argcomplete separately. I'll think of a way to test it.