-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
47 deletions.
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,25 @@ | ||
#include <structopt/app.hpp> | ||
|
||
struct Options { | ||
// positional arguments | ||
std::string input_file; | ||
std::string output_file; | ||
|
||
// optional arguments | ||
std::optional<std::string> bind_address; | ||
|
||
// remaining arguments | ||
std::vector<std::string> files; | ||
}; | ||
STRUCTOPT(Options, input_file, output_file, bind_address, files); | ||
|
||
int main(int argc, char *argv[]) { | ||
|
||
try { | ||
const std::string& custom_help = "Usage: ./my_app input_file output_file [--bind-address BIND_ADDRESS] [files...]\n"; | ||
auto options = structopt::app("my_app", "1.0.3", custom_help).parse<Options>(argc, argv); | ||
} catch (structopt::exception &e) { | ||
std::cout << e.what() << "\n"; | ||
std::cout << e.help(); | ||
} | ||
} |