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 '[args]' and 'Valid Args:' to --help #842

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

umarcor
Copy link
Contributor

@umarcor umarcor commented Mar 20, 2019

Close #571 and Close #576.

This PR is based on #841, and it must be merged after that. See difference: umarcor/cobra@feat-matchvalid...umarcor:feat-validinhelp

The added feature is to modify the output of Usage() to print [args] if the command accepts args:

Usage:
  app [args]              # instead of 'app'
  app [flags] [args]      # instead of 'app [flags]'
  app [command]

Valid Args:
  one two three
  • app [args] and app [flags] [args] are not shown at the same time.
  • [args] is only added if the command is runnable, and Args != NoArgs, or Args == nil && (!c.HasAvailableSubCommands() || c.HasParent()), etc.
  • Valid Args is only shown if ValidArgs is not empty and [args] is shown.

To Do

  • As suggested in #571:
    • When MinimumNArgs, ExactArgs or RangeArgs are used, args should be shown instead of [args].
    • The Usage() should show the constraints applied to the args (NArgs>x, NArgs<x, NArgs=x or x<NArgs<y).

These have not been implemented yet, because I don't know any easy mechanism to detect the type of c.Args.

@umarcor
Copy link
Contributor Author

umarcor commented Jun 7, 2019

Ref #666, Ref #635 and Ref #706.

README.md Outdated Show resolved Hide resolved
@umarcor umarcor force-pushed the feat-validinhelp branch 3 times, most recently from 6b60c76 to 145ff21 Compare January 6, 2020 22:38
@umarcor umarcor force-pushed the feat-validinhelp branch 2 times, most recently from 31007ba to 3e25070 Compare November 16, 2021 22:39
@umarcor umarcor force-pushed the feat-validinhelp branch 2 times, most recently from d4e6320 to 04b13c1 Compare December 14, 2021 19:27
@umarcor umarcor force-pushed the feat-validinhelp branch 3 times, most recently from f3fd262 to 86e690d Compare February 18, 2022 05:06
@umarcor
Copy link
Contributor Author

umarcor commented Feb 25, 2022

This PR is not stale, but blocked by #841. Please, remove the kind/stale label.
See #1496 (comment) and #1496 (comment).

@umarcor umarcor force-pushed the feat-validinhelp branch from d2d0de4 to 772473b Compare March 3, 2022 08:43
@marckhouzam marckhouzam added lifecycle/frozen Prevents GitHub actions from labeling issues / PRs with stale and rotten and removed kind/stale labels Mar 3, 2022
@umarcor umarcor force-pushed the feat-validinhelp branch 2 times, most recently from a4a3b1c to 7684682 Compare March 17, 2022 10:31
@umarcor umarcor force-pushed the feat-validinhelp branch 2 times, most recently from d51b602 to d7a7e6d Compare March 22, 2022 18:40
@github-actions github-actions bot added the size/XL Denotes a PR that exceeds 200 lines. Caution! label Aug 21, 2022
@github-actions
Copy link

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Prevents GitHub actions from labeling issues / PRs with stale and rotten size/XL Denotes a PR that exceeds 200 lines. Caution!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting --help to print descriptions for arguments Missing ValidArgs on help
3 participants