MCPcopy Create free account
hub / github.com/Taywee/args / Add

Function Add

examples/gitlike.cxx:91–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void Add(const std::string &progname, std::vector<std::string>::const_iterator beginargs, std::vector<std::string>::const_iterator endargs)
92{
93 std::cout << "In Add" << std::endl;
94 args::ArgumentParser parser("");
95 parser.Prog(progname + " add");
96 args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"});
97 args::Flag dryrun(parser, "dryrun", "dry run", {'n', "dry-run"});
98 args::Flag verbose(parser, "verbose", "be verbose", {'v', "verbose"});
99 args::Flag refresh(parser, "refresh", "Don't add, only refresh the index", {"refresh"});
100 args::PositionalList<std::string> pathspec(parser, "pathspec", "pathspecs");
101 try
102 {
103 parser.ParseArgs(beginargs, endargs);
104 std::cout << std::boolalpha;
105 std::cout << "dryrun: " << bool{dryrun} << std::endl;;
106 std::cout << "verbose: " << bool{verbose} << std::endl;
107 std::cout << "refresh: " << bool{refresh} << std::endl;
108 std::cout << "pathspec: " << bool{pathspec} << std::endl;
109 if (pathspec)
110 {
111 std::cout << "values: " << std::endl;
112 for (const auto &spec: args::get(pathspec))
113 {
114 std::cout << " - " << spec << std::endl;
115 }
116 }
117 }
118 catch (args::Help)
119 {
120 std::cout << parser;
121 return;
122 }
123 catch (args::ParseError e)
124 {
125 std::cerr << e.what() << std::endl;
126 std::cerr << parser;
127 return;
128 }
129}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected