How to use C ++ getopt_long () if I have more than 26 options?

This is a rather hypothetical question, but let me say that I have 3 long parameters starting with the same letter.

--parse or -p
--prune or -r
--pivot or -i

In the end, I will start to exhaust individual letters that make sense; moreover, it is difficult to assign something meaningful to the GNU getopt_long () setting .

{"parase", no_argument,       0, 'p'},
{"prune",  no_argument,       0, 'r'},
{"pivot",  required_argument, 0, 'i'}

What is the best practice in these situations?

+5
source share
4 answers

, , 52 , , , , , .

+5

val. , int, char. . ( , shorty).

+6

0-9. , -compression=[0-9], -[0-9] ( , getopt).

In addition, upper case can be used.

I understand that a hypothetical question, but with so many options, the program is probably too much or needs a configuration file.

+1
source

I would advise you to take a look at increasing program parameters . This is a universal library for receiving command line arguments. Very light and pleasant to use.

0
source

All Articles