0

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

selbie
  • 100,020
  • 15
  • 103
  • 173
Bruce
  • 2,230
  • 18
  • 34

4 Answers4

3

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

Manu343726
  • 13,969
  • 4
  • 40
  • 75
  • 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
  • 26,924
  • 5
  • 64
  • 92
1

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

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
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
  • 100,020
  • 15
  • 103
  • 173