Cli: v2 feature: print text to indicate when a command is a sub-command

Created on 12 Feb 2020  路  8Comments  路  Source: urfave/cli

Checklist

  • [x] Are you running the latest v2 release?
  • [x] Did you check the manual for your release?
  • [x] Did you perform a search about this feature?

What problem does this solve?

  • Need to print a text to know when a command is really a sub-command; when the help is printed, it shows a section called 'COMMANDS' where could have some sub-commands.

Solution description

I would want that after of the name were printed a text like i.e. (sub-command)

arev2 help wanted statuconfirmed statustale

All 8 comments

@tredoe I don't quite understand the use case, can you give me an example of what the help output would look like? It might just be that I'm not imagining it correctly.

@lynncyrin At the main help of the command, there is a section called COMMANDS where you could have a command with sub-commands, and I think that would be very well if could be printed some text to know wich ones are they. Or even, those commands with sub-commands could be into other section.

@tredoe that's not an example 馃槤

The main help of a tool could be like this one:

./foo -h
NAME:
   foo - Tool to ...

USAGE:
   foo [global options] command [command options] [arguments...]

VERSION:
   1.0.0

COMMANDS:
   new         Create ...
   help, h     Shows a list of commands or help for one command
   Database:
     adduser   Add ...
     deluser   Remove ...
     mig       Migration ...
   Information:
     infodb  Print ...
     dsn     Print ...

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

From all those commands, there is one which has other commans or sub-commands:

./foo mig -h
NAME:
   foo mig - Migration ...

USAGE:
   foo mig command [command options] [arguments...]

COMMANDS:
   setup    Create ...
   new      Create ...
   id       Display ...
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

I think I'm seeing it now, I could imagine something like this

./foo -h
NAME:
   foo - Tool to ...

USAGE:
   foo [global options] command [command options] [arguments...]

VERSION:
   1.0.0

COMMANDS:
   new          Create ...
   mig          Migration ...
      setup         Create ...
      new           Create ...
      id            Display ...

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

I think that'd be valuable 馃憤

Offhand, I'm not sure what we do here currently? We might just ignore the subcommands?

I like that output, where you see from the main help all commands and sub-commands.

This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

Closing this as it has become stale.

Was this page helpful?
0 / 5 - 0 ratings