Gelio / go-global-update

A command to update globally installed go executables
MIT License
134 stars 4 forks source link

Short options for commands (POSIX syntax) #15

Closed zeraye closed 2 years ago

zeraye commented 2 years ago

Your commands only has support for long options specified as --option-name. I would love to see short options which are in POSIX convention. I has come with some propositions:

Debug option is just more verbose 'verbose option'. This approach is used in rsync command see. If you want to see more about verbosity levels look at this.

zeraye commented 2 years ago

For --color you can use -C (capitalized) same as in ls command see.

Gelio commented 2 years ago

Thanks for submitting the issue :+1: Adding aliases definitely makes sense. I agree with the 3 aliases you suggested (-n, -v, -vvv). I'll add -n and -v soon. As for -vvv, I'd be afraid that the library we are using for parsing CLI arguments will assume that an option whose name is longer than a single character should be prefixed by double dashes (--vvv) instead of a single dash (-vvv). I will try it out and skip that option if there will be problems

I'm not so sure about --colors. It's not every day that you should use that option since it should be most useful in scripts, where I would value the clarify provided by using full option names. Moreover, looking at the man page for ls which you shared, I see the -C option is for listing entries in columns, not for enabling colors. ls only has the full --color option for colors, which seems to match what go-global-update is doing :smile:

zeraye commented 2 years ago

I'm now convinced that alias for --colors is unnecessary. You are right that it can decrease readability. About verbosity, maybe there is a way to use FLAGS? Multi letters options for POSIX syntax are not available, but something like -v=3 for --debug may work?

Gelio commented 2 years ago

I checked and vvv is indeed interpreted by the CLI tool as --vvv, which is not great:

GLOBAL OPTIONS:
   --debug, --vvv  Display debug information (default: false)

As for -v=3, I would be surprised seeing that used in a script or copy-pasting that code :smile: It could also suggest there are other values you could use like -v=5 or -v=1 (which would be equivalent to -v). It also overloads the -v to sometimes be a boolean flag and sometimes a numeric flag, which I am not sure the CLI args parser would handle

--debug is also not a flag you use commonly, so I hope it's ok users would type 7 letters (--debug) instead of 4 (with -v=3)

Gelio commented 2 years ago

I have just merged #16 which is supposed to fix this issue. I have released v0.2.1 with that change

Thanks again for reporting the issue :+1: