dnaeon / clingon

Command-line options parser system for Common Lisp
Other
122 stars 7 forks source link

--version for subcommands #6

Closed alessiostalla closed 1 year ago

alessiostalla commented 1 year ago

Subcommands list a --version option but that doesn't seem to do anything:

$ ./portofino new --help
NAME:
  portofino new - Create a new Portofino project

USAGE:
  portofino [global-options] new [options] [arguments ...]

OPTIONS:
     [...]
      --version                    display version and exit
     [...]

$ ./portofino new --version
[no output]      
dnaeon commented 1 year ago

This is because you haven't specified a value for the :version slot of the sub-command.

The idea behind this is that sub-commands may have a different version than the parent command. As an example, I may be building a CLI tool where I develop some part of the code, and then I can pull in as a dependency some other system/package, which provides another set of commands in order to have one single CLI which combines multiple commands from different packages/systems.

I've also pushed a commit, which now tries to find a parent command, for which there is a :version associated with.

https://github.com/dnaeon/clingon/commit/2f1a479e2c97a648d6d88858ffd5e55419b08779

Try it out and let me know how it goes.

alessiostalla commented 1 year ago

Yep, that was it, thanks!