#2067·cli

Allow to use a subcommand after a positional argument

Author: iTroozCreated Mar 2, 2025Updated Apr 13, 2026
Labelskind/featurearea/v3

Hey ! I'd like to create a urfave command to manage nested resources, and would like a CLI interface like this:

bash
$ manage author <authorID> book <bookID> delete

(Books aren't identifiable in a unique way)

AFAIK, there is currently no way to have a command structure like this in urfave, because we cannot set a subcommand that takes places after a positional argument.

Implementation ideas:

  • a cli.Command implementation that would eat any argument instead of specifically the Name argument, and store it in the command context (this cannot work because cli.Command is a struct, not an interface)
  • a StoreValue field in cli.Command that, if set to true, would eat the next argument and store it in the command context
  • A way to use Before in a cli.Command to eat the next parameter and store it in the context

What do you think about this feature ?