This template should include command-line argument handling, version, and help. Otherwise, can you suggest a link to a developer's guide?
Asked
Active
Viewed 868 times
0
-
getopt manual, perhaps? – Nicholas Wilson Dec 23 '13 at 18:56
-
2"Is there a standard pattern for writing a linux command-line utility in C++?" - yeah, write it in C. – Dec 23 '13 at 19:00
4 Answers
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
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
-
GNU libc also gives the `getopt_long` function which might be more useful.... – Basile Starynkevitch Dec 24 '13 at 11:46