Questions tagged [boost-program-options]

Boost.Program_options is a C++ library that allows program developers to obtain (name, value) pairs from the user via conventional methods such as command line and config file.

Boost.Program_options is a C++ library that allows program developers to obtain program options, that is (name, value) pairs from the user, via conventional methods such as command line and config file.

Why would you use such a library, and why is it better than parsing your command line by straightforward hand-written code?

  • It's easier. The syntax for declaring options is simple, and the library itself is small. Things like conversion of option values to desired type and storing into program variables are handled automatically.
  • Error reporting is better. All the problems with the command line are reported, while hand-written code can just misparse the input. In addition, the usage message can be automatically generated, to avoid falling out of sync with the real list of options.
  • Options can be read from anywhere. Sooner or later the command line will be not enough for your users, and you'll want config files or maybe even environment variables. These can be added without significant effort on your part.
381 questions
0
votes
0 answers

How to validate value along with key in parsing ini file

I'm using boost::program_options to parse ini file. Simple ini file parsing is easy with program_options. I can add allowed options and it would automatically validate the options. Is there any way to validate the value? Suppose I want to allow…
user832096
  • 373
  • 1
  • 6
  • 15
0
votes
1 answer

Command line argument / program option parsing Styles and Specification?

I am curious if there are any extensive overview, preferrably specifications / technical reports about the GNU style and other commonly used styles for parsing Command Line Arguments. As far as I know, there are many catches and it's not completely…
0
votes
0 answers

Boost Program Options help string cannot be modified based on chosen styles

One of the things I want to do when I use Program Options is to print the help string according to the styles I want to enforce. For example, on Windows if I use: allows_slash_for_short it will make sense for me to reflect that when I print the…
CppNoob
  • 2,322
  • 1
  • 24
  • 35
0
votes
1 answer

Boost program options with default value

I have a console application in c++ using boost program_options. I have a parameter named --list-timezones now I want to use it like that either myapp --list-timezones which gives me all available timzones or myapp --list-timezones AT which…
user2071938
  • 2,055
  • 6
  • 28
  • 60
0
votes
1 answer

Boost program options and shared_ptr

I am trying to use a class to dynamically assemble program options for different applications. When using plain pointers for desc everything works fine. In the following case with shared_ptr the parser does not recognize the added program…
user2970139
  • 557
  • 5
  • 13
0
votes
1 answer

I am unable to emulate subcommands using positional options followed by unregistered_options

I am trying to emulate something like this: apple --color red --count 5 orange --taste sour Where I intend to make apple and orange as positional_option: subCommand and I intend to capture the remainder of options with values as unregistered…
attu013
  • 31
  • 7
0
votes
1 answer

Change the comment character in Boost Program Options?

I have an app that has components in both PHP and C++. They need to share some configuration options, and I'd like to use one file to share these -- a simple config file. Fortunately, PHP has parse_ini_file() and Boost has Program Options and they…
CLWill
  • 148
  • 1
  • 5
0
votes
1 answer

How do I get a handle to split_winmain

I am trying to get a get the boost library program_options working on a simple windows console library. I have linked in the library C:\Program Files\boost\boost_1_40\lib\libboost_program_options-vc90-s-1_40.lib Included the header files #include…
Joseph Shanahan
  • 197
  • 1
  • 1
  • 10
0
votes
1 answer

Boost Program Options is silently ignoring unknown value tokens. why?

I'm using Boost Program Options to parse CLI. The problem I'm facing is that if there is any token in CLI without '-' or '--' in front of it, the library silently ignores it instead of throwing exception. Following is the sample program: try { …
anni
  • 338
  • 2
  • 12
0
votes
1 answer

What is the format of BOOST program options command lines?

I have two switches, 'i' and 'p' that represent IPAddress and Port respectively. What is the format of the command line? I have tried: app -i192.168.1.1 -p12345 app -i 192.168.1.1 -p 12345 app -i=192.168.1.1 -p=12345 app -i='192.168.1.1'…
bentaisan
  • 1,056
  • 3
  • 12
  • 29
0
votes
2 answers

Read one parameter from config file where there are more parameters, with boost program_options

I have a cfg file as the following: parameter1="hello" parameter2=22 parameter3=12 Using boost_program to read all the parameters works fine with this code: po::options_description options("Options"); options.add_options() ("help,h", "produce…
0
votes
1 answer

Another boost error

On this code I get the enourmous error static void ParseTheCommandLine(int argc, char *argv[]) { int count; int seqNumber; namespace po = boost::program_options; std::string appName = boost::filesystem::basename(argv[0]); po::options_description…
user1676605
  • 1,337
  • 3
  • 13
  • 21
0
votes
2 answers

Boost boost_program_options-gcc41-mt-1_39.a undefined symbol errors while doing static linking

While trying to link boost program option library statically in my code I am getting below error while linker try to link it. gmake[1]: Leaving directory `tools' g++ -rdynamic -g -o test test.o…
Abhinav
  • 975
  • 4
  • 18
  • 35
0
votes
3 answers

using boost::program_options as static members of a class

Basically it is the following code, which cannot pass compiler (g++) #include #include using std::cout; using std::endl; namespace po = boost::program_options; class static_class { public: static…
Wei Song
  • 545
  • 3
  • 11
0
votes
1 answer

Is there an equivalent of Boost.Program_options in lua?

I'd like to be able to take program options from the command line and from a file. If there is no close equivalent, what is the common way to make config files? I like the boost.po but I don't like that I can't script in the config files. for…
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
1 2 3
25
26