-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from CLIUtils/prefix_program
Prefix program support
- Loading branch information
Showing
6 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "CLI/CLI.hpp" | ||
|
||
int main(int argc, char **argv) { | ||
|
||
CLI::App app("Prefix command app"); | ||
app.prefix_command(); | ||
|
||
std::vector<int> vals; | ||
app.add_option("--vals,-v", vals) | ||
->expected(1); | ||
|
||
std::vector<std::string> more_comms; | ||
try { | ||
more_comms = app.parse(argc, argv); | ||
} catch(const CLI::ParseError &e) { | ||
return app.exit(e); | ||
} | ||
|
||
std::cout << "Prefix:"; | ||
for(int v : vals) | ||
std::cout << v << ":"; | ||
|
||
std::cout << std::endl << "Remaining commands: "; | ||
|
||
// Perfer to loop over from beginning, not "pop" order | ||
std::reverse(std::begin(more_comms), std::end(more_comms)); | ||
for(auto com : more_comms) | ||
std::cout << com << " "; | ||
std::cout << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters