Skip to content

Instantly share code, notes, and snippets.

@philsquared
Created August 7, 2018 17:00
Show Gist options
  • Save philsquared/0f0efe13e2b503a254bcaf9aeb039c43 to your computer and use it in GitHub Desktop.
Save philsquared/0f0efe13e2b503a254bcaf9aeb039c43 to your computer and use it in GitHub Desktop.
#include "clara.hpp"
#include <iostream>
int main( int argc, char** argv ) {
int count = 0;
using namespace clara;
auto cli = Parser() | Opt( [&]( bool ) { count++; } )
["-s"];
cli.parse( Args{ argc, argv } );
std::cout << "Repeated: " << count << ", effective " << std::boolalpha << (count%2==1) << " (Command line was:";
while (*argv) std::cout << " " << *argv++;
std::cout << ")\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment