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 subcommand aliases #231

Merged
merged 3 commits into from
Oct 10, 2023
Merged

add subcommand aliases #231

merged 3 commits into from
Oct 10, 2023

Conversation

alexflint
Copy link
Owner

With this PR it is possible to define aliases for subcommands like this:

var args struct {
    Remove *struct{} `arg:"subcommand:remove|rm|r" help:"remove something from somewhere"`
}

You can then write ./myprogram remove or ./myprogram rm or ./myprogram r

They show up in the help output like this:

Usage: example <command> [<args>]

Options:
  --help, -h             display this help and exit

Commands:
  remove, rm, r          remove something from somewhere

Originall I wanted to use tag syntax subcommand:remove,rm,r but I couldn't because the commas are already defined to be a separator at a higher level so it would create trouble to write something like subcommand:blah,help:something. I decided to go with pipes instead.

Closes #230

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (5ec29ce) 99.19% compared to head (e7a4f77) 99.17%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #231      +/-   ##
==========================================
- Coverage   99.19%   99.17%   -0.02%     
==========================================
  Files           5        5              
  Lines         745      731      -14     
==========================================
- Hits          739      725      -14     
  Misses          3        3              
  Partials        3        3              
Files Coverage Δ
parse.go 99.52% <100.00%> (+<0.01%) ⬆️
subcommand.go 100.00% <100.00%> (ø)
usage.go 97.68% <100.00%> (-0.28%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexflint alexflint merged commit bf629a1 into master Oct 10, 2023
5 checks passed
@alexflint alexflint deleted the subcommand-aliases branch October 10, 2023 22:36
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.

Feature request: Alias for subcommands
2 participants