Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shell autocomplete #228

Merged
merged 5 commits into from
Aug 12, 2019
Merged

Conversation

cs01
Copy link
Contributor

@cs01 cs01 commented Aug 4, 2019

To try this out in bash run the following. Other shells also have limited support. See instructions in the docs in this PR.

pip install .  # from nox directory since a new dependency is required
eval "$(register-python-argcomplete nox)"
nox <tab>
nox --<tab>
nox -s <tab>

A sample of the autocompletions for all items that start with a --:
image

The _session_completer function provides a list of sessions when hitting tab in nox -s <tab>. argcomplete provides parsed_args to this function, which is the Namespace argparse would have returned if the program were actually run. This corresponds almost directly to nox's global_config, and it works out of the box 😄 .

Note that this adds a new dependency to nox in setup.py, argcomplete.

fixes #227

cc @theacodes

@cs01
Copy link
Contributor Author

cs01 commented Aug 4, 2019

I see travis is failing because this drops below 100% coverage. I don't really have the time/desire to write tests for this at the moment, but I might at some point. I created the PR with the ability to add edits from maintainers if anyone would like to add them.

@cs01
Copy link
Contributor Author

cs01 commented Aug 10, 2019

@theacodes are you okay with the addition of a new dependency, argcomplete?

Some good things about it

  • It has no dependencies of its own
  • It's actively maintained
  • It works for multiple shells
  • It's dynamically generated based on nox's arguments. This means the nox maintainers don't have to continuously update and test custom shell completion scripts.

Downside

  • Additional dependency

Other options

  • Add an extra such as nox[completions] to nox's setup.py so it's not included in the base nox package. This requires a little extra overhead for those that want shell completions, but avoids forcing that requirement on all nox installations.

@theacodes
Copy link
Collaborator

theacodes commented Aug 11, 2019 via email

@cs01
Copy link
Contributor Author

cs01 commented Aug 11, 2019

Great! We should be good, and also have the extra safety of limiting the versions nox requires (>=1.9.4, <2.).

I will work on getting this test passing now.

@cs01
Copy link
Contributor Author

cs01 commented Aug 11, 2019

Tests have been added and CI is now passing.

@theacodes theacodes merged commit 9f2f32b into wntrblm:master Aug 12, 2019
@theacodes
Copy link
Collaborator

This is rad, thank you @cs01!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

shell completion
2 participants