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

Feature: Group flags by feature (essentially FlagSets) #12

Open
briancain opened this issue Feb 21, 2024 · 2 comments
Open

Feature: Group flags by feature (essentially FlagSets) #12

briancain opened this issue Feb 21, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@briancain
Copy link
Member

Currently, there's no way in this project to define group flags in a command where flags are related. For example, with mitchell/cli you could define groups of flags known as FlagSets so the help shows them together as related fields.

With the current project, it groups all flags as equal under FLAGS. Any commands that take a lot of options will become pretty messy and hard to understand what is related to what without grouping flags.

brian@brian-LNQ0KYW6HD:hcp λ ./bin/hcp waypoint action-config create -help ±[●][waypoint/add-action-config-cli]
USAGE
  hcp waypoint action-config create [Optional Flags]

DESCRIPTION
  Create a new action configuration.

FLAGS
  -d, --description
    The description of the action configuration.

  -n, --name
    The name of the action configuration.

  -u, --url
    The URL of the action configuration.

  -x, --example-feature-1
    My cool feature unrelated to the other thing.

  -y, --example-feature-A
    My cool feature unrelated to the other thing.

GLOBAL FLAGS
  --format=FORMAT, --profile=NAME, --project=ID, --quiet

  For more global flag details, run $ hcp --help

With flag sets, help becomes much more useful:

brian@brian-LNQ0KYW6HD:hcp λ ./bin/hcp waypoint action-config create -help ±[●][waypoint/add-action-config-cli]
USAGE
  hcp waypoint action-config create [Optional Flags]

DESCRIPTION
  Create a new action configuration.

FLAGS
  -d, --description
    The description of the action configuration.

  -n, --name
    The name of the action configuration.

CUSTOM REQUEST FLAGS
  -u, --url
    The URL of the action configuration.

FEATURE 1 FLAGS

  -x, --example-feature-1
    My cool feature unrelated to the other thing.

FEATURE 2 FLAGS

  -y, --example-feature-A
    My cool feature unrelated to the other thing.

GLOBAL FLAGS
  --format=FORMAT, --profile=NAME, --project=ID, --quiet

  For more global flag details, run $ hcp --help

This CLI project should support FlagSets so that commands with lots of configurations can group flags together for easier understanding.

@dadgar
Copy link
Contributor

dadgar commented Feb 21, 2024

How would you imagine capturing required vs non required. I was planning on having flag groups live under the respective categories that exist today.

USAGE
  hcp waypoint action-config create [Optional Flags]

DESCRIPTION
  Create a new action configuration.

REQUIRED FLAGS
  -d, --description
    The description of the action configuration.

  -n, --name
    The name of the action configuration.

OPTIONAL FLAGS
  -u, --url
    The URL of the action configuration.

  Flags for example Feature 1:

  -x, --example-feature-1
    My cool feature unrelated to the other thing.

  -y, --example-feature-A
    My cool feature unrelated to the other thing.

GLOBAL FLAGS
  --format=FORMAT, --profile=NAME, --project=ID, --quiet

  For more global flag details, run $ hcp --help

Thoughts?

@briancain
Copy link
Member Author

In all honesty I'd probably do whatever mitchell/cli or spf13/cobra does since they are pretty established CLI tools 😅 Just based on what I've experienced, I think I'd expect to see a Required string on the flag description, maybe after the flag definition.

  -n, --name
    The name of the action configuration. (Required, Defaults to "example")

You could also show required flags by auto-generating the usage and auto-including required flags

USAGE
  hcp waypoint action-config create -name="your-action-name" [Optional Flags]

@dadgar dadgar added the enhancement New feature or request label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants