7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-22 03:35:02 +00:00
kicad/thirdparty/argparse/samples/optional_flag_argument.cpp
2023-12-17 21:29:05 -05:00

25 lines
548 B
C++

// SPDX-License-Identifier: MIT
#include <argparse/argparse.hpp>
int main(int argc, char *argv[]) {
argparse::ArgumentParser program("test");
program.add_argument("--verbose")
.help("increase output verbosity")
.default_value(false)
.implicit_value(true);
try {
program.parse_args(argc, argv);
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
}
if (program["--verbose"] == true) {
std::cout << "Verbosity enabled" << std::endl;
}
}