Simple test program for GetOpt. Binary should be installed as ui-utilcpp-getopt.
#include "config.h"
#include <iostream>
int main(int argc, char *argv[])
{
int retValue(0);
getOpt
.
set(
"version",
'v', UI::Util::GetOpt::NoArg_,
"Show version information.")
.
set(
"help",
'h', UI::Util::GetOpt::NoArg_,
"Show usage information.")
.
set(
"noarg",
'n', UI::Util::GetOpt::NoArg_,
"Option with no argument.")
.
set(
"arg",
'a', UI::Util::GetOpt::Arg_,
"Option with mandatory argument.")
.
set(
"optarg",
'o', UI::Util::GetOpt::OptArg_,
"Option with optional argument.");
{
}
{
std::cout << "Release: " << PACKAGE << "-" << VERSION << "." << std::endl << std::endl;
}
{
std::cout << std::endl << "Blah tool to do blah." << std::endl;
}
else
{
{
std::cout << "Option \"noarg\" given." << std::endl;
}
{
std::cout << "Option \"arg\" given." << std::endl;
std::cout <<
"Argument is: " << getOpt.
get(
"arg")->
getArg() << std::endl;
}
{
std::cout << "Option \"arg\" given." << std::endl;
std::cout <<
"Argument is: " << getOpt.
get(
"optarg")->
getArg() << std::endl;
}
std::cout << "Program Main Run" << std::endl;
std::cout << "Try --help if you want to test GetOpt" << std::endl;
}
return retValue;
}