lirantal/nodejs-cli-apps-best-practices

New Experience best practice request: version information

lirantal opened this issue ยท 7 comments

Looking for someone who would be interesting to contribute a new item on proper version usage.

My take on it would be around:

  • A program should support --version and -v to inspect the installed version

Further info that can be elaborated in details: A program may choose to show its version when being run in order to easily surface the version to users. Example of this is Yarn.

Is there strong consensus on -v being used as an alias for --version? Many GNU and other "long-lived" CLIs use the short-v as a flag for verbose. Indeed, some tooling even increases the verbosity level based on the number of Vs.

-v: "debug"
-vv: "trace"
-vvv: "silly"
--version: version info

I did some research on version flags for Commander: tj/commander.js#1621 (comment)

The long flag --version is very common, the short flag varies. The references I found cover the full spread, one -v, one -V, and one mentioned both verbose and version for -v!

@jasonkarns good point indeed. I don't have a strong opinion on forcing that, but rather to have some good research on conventions, hopefully, those that also apply and have been employed in POSIX compliant tooling so this would indeed not confuse users.

@shadowspawn thank you for chiming in (๐ŸŽ‰). How about we kick this off with a PR for updating this information as part of the best practices section and go with --version as the recommended one. In the details part, we can share the pitfalls as to why it might not be a good idea to add -v as a short flag. @shadowspawn would you like to take it up to push a PR?

(I won't volunteer to take it up thanks, busy elsewhere. But I might get to it some quiet day when I am looking for something to contribute to!)