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 support for help for CLI arguments #123

Merged
merged 22 commits into from
Jun 24, 2020
Merged

✨ Add support for help for CLI arguments #123

merged 22 commits into from
Jun 24, 2020

Conversation

tiangolo
Copy link
Member

✨ Add support for help for CLI arguments.

As this is not supported by Click, this PRs does a lot of work sub-classing the necessary Click internal classes to add support for help parameters for CLI arguments, and all the relevant related parameters (e.g. show_default, hidden, etc).

CLI programs built with Typer will have an Arguments section with consistent formatting, showing default values, etc.

The new classes (Click sub-classes) also update a bit the way CLI arguments are shown in the help text to make the name of the CLI argument obvious even if it's an enum, date, or has default values.

This will make it easy to visually understand the relationship between the names shown in the Usage line (the first line) and the Arguments section.

Because these new classes re-reimplement a lot of the logic existing for CLI options, but for CLI arguments, there's a lot of new docs, and a lot of new tests testing those docs, keeping coverage at 100%. 💯

This also makes show_default and show_envvar default to True. ✨ With this, by default, any CLI program will show all the information when there's information to show instead of requiring manually turning it on.

@github-actions
Copy link

@codecov
Copy link

codecov bot commented Jun 24, 2020

Codecov Report

Merging #123 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master      #123    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          216       242    +26     
  Lines         4057      4502   +445     
==========================================
+ Hits          4057      4502   +445     
Impacted Files Coverage Δ
docs/src/arguments/default/tutorial001.py 100.00% <ø> (ø)
docs/src/arguments/optional/tutorial001.py 100.00% <ø> (ø)
..._parameter_types/test_datetime/test_tutorial001.py 100.00% <ø> (ø)
typer/params.py 100.00% <ø> (ø)
docs/src/arguments/default/tutorial002.py 100.00% <100.00%> (ø)
docs/src/arguments/envvar/tutorial001.py 100.00% <100.00%> (ø)
docs/src/arguments/envvar/tutorial002.py 100.00% <100.00%> (ø)
docs/src/arguments/envvar/tutorial003.py 100.00% <100.00%> (ø)
docs/src/arguments/help/tutorial001.py 100.00% <100.00%> (ø)
docs/src/arguments/help/tutorial002.py 100.00% <100.00%> (ø)
... and 54 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 338d05f...f37ea3d. Read the comment docs.

@github-actions
Copy link

@github-actions
Copy link

@tiangolo tiangolo merged commit 15380dd into master Jun 24, 2020
@tiangolo tiangolo deleted the args-with-help branch June 24, 2020 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant