Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the basic arguments every good CLI application must have?

myapp /?

myapp -help

myapp -ver

etc....

like image 826
Jakob Cosoroaba Avatar asked Jun 13 '09 08:06

Jakob Cosoroaba


3 Answers

GNU Coding Standards mandate --version and --help and I've come to expect any CLI program to support these. Other than that, it really depends on what the program is, but here are some other suggestions: -q or --quiet for less output, -v or --verbose for more output, -d or --debug for debugging output.

like image 134
Laurynas Biveinis Avatar answered Oct 14 '22 23:10

Laurynas Biveinis


It depends on the platform.

On Windows, /? or /h or /help are common.

On Unix, a command should have a man page.

On Unix variants in which Gnu conventions are followed (e.g. Linux), it should respond to --help and --version. Even better, it can integrate with bash autocompletion.

Apart from that, look at other programs' in the same area as yours and use the same options where it makes sense. E.g.:

  • -r/--recursive to recurse down directories
  • -q/--quiet to suppress output
  • -v/--verbose to generate verbose, diagnostic output
  • -n to execute without changing anything

If your program accepts file names as arguments then common convention is for a single hyphen to mean 'read from stdin' and a double hyphen to mean 'treat the next argument as a file even if it begins with a hyphen'.

like image 21
Nat Avatar answered Oct 14 '22 21:10

Nat


A short and long version of command line arguments. Check if there is a getopt library port for the programming language that you use. It will help you in parsing command line arguments.

--config-file=FILE | -C FILE
--help | -h
--usage | -u
--version | -v

Include other relevant options for your application.

like image 32
Alan Haggai Alavi Avatar answered Oct 14 '22 23:10

Alan Haggai Alavi