* This file is a part of LEMON, a generic C++ optimization library
* Copyright (C) 2003-2008
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
///\brief Argument parser demo
/// This example shows how can the argument parser used.
/// \include arg_parser.cc
#include <lemon/arg_parser.h>
int main(int argc, const char **argv)
ap.refOption("n", "an integer input", i, true)
.refOption("val", "a double input", d)
.refOption("name", "a string input", s)
.refOption("f", "a switch", b)
.refOption("nohelp", "", sil)
.refOption("gra","Choise A",g1)
.refOption("grb","Choise B",g2)
.refOption("grc","Choise C",g3)
.other("infile","The input file")
std::cout << "Parameters of '" << ap.commandName() << "':\n";
if(ap.given("n")) std::cout << " Value of -n: " << i << std::endl;
if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl;
if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl;
if(ap.given("f")) std::cout << " -f is given\n";
if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << sil << std::endl;
switch(ap.files().size()) {
std::cout << " No file argument was given.\n";
std::cout << " 1 file argument was given. It is:\n";
<< ap.files().size() << " file arguments were given. They are:\n";
for(unsigned int i=0;i<ap.files().size();++i)
std::cout << " '" << ap.files()[i] << "'\n";