0

This template should include command-line argument handling, version, and help. Otherwise, can you suggest a link to a developer's guide?

selbie
  • 91,215
  • 14
  • 97
  • 163
Bruce
  • 2,152
  • 17
  • 31

4 Answers4

3

You could use a library which manages command line argumments. I recommend you the boost::program_options library.

Manu343726
  • 13,596
  • 3
  • 37
  • 73
  • The Boost options lib is a convenient tool but I don't think it (or the associated docs) has much to say about designing the options for linux conventions. – ValenceElectron Dec 23 '13 at 20:06
1

The POSIX guidelines for utilities are here and conventions succinctly described here. GNU extensions are common and I think pretty much expected on Linux.

Jonathan Leffler wrote a nice answer here which delves into some of this as well.

Community
  • 1
  • 1
Duck
  • 25,966
  • 4
  • 61
  • 89
1

In addition of other answers, I would suggest considering GNU libc argp functions.

Basile Starynkevitch
  • 216,767
  • 17
  • 275
  • 509
0

There isn't any sort of standard pattern per se. Once glance at the source for many of your favorite command line apps will reveal it's even more ad-hoc than you think.

Command line parsing is typically done with the getopt function. As for help and version. Either printf or cout.

You could also take a read of The Art Of Unix Programming about expected behaviors of command line programs in UNIX.

selbie
  • 91,215
  • 14
  • 97
  • 163