Rella
Rella

Reputation: 66995

Is there any opensource cross platform C++ library for creating menus for command line projects?

So what I need on developer side is something like

addoption("-use-something", "Use Something instead of Some other thing", localVarName, desiredValue, defauultValue);

While on user side I wish to see 3 things

Upvotes: 0

Views: 347

Answers (2)

Tarantula
Tarantula

Reputation: 19902

You should use the Boost.Program_options. Example from the tutorial:

// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
    ("help", "produce help message")
    ("compression", po::value<int>(), "set compression level")
;

po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);    

if (vm.count("help")) {
    cout << desc << "\n";
    return 1;
}

if (vm.count("compression")) {
    cout << "Compression level was set to " 
 << vm["compression"].as<int>() << ".\n";
} else {
    cout << "Compression level was not set.\n";
}

Upvotes: 1

manol
manol

Reputation: 582

Look at the answers of Option Parsers for C/C++?

Upvotes: 2

Related Questions