Cleanup example program in Flag docs.
This commit is contained in:
parent
a0cd2ca866
commit
b7584b06cc
26
Flag.h
26
Flag.h
|
@ -92,41 +92,43 @@ Flag *NewFlag(std::string fName, FlagType fType, std::string fDescription);
|
||||||
///
|
///
|
||||||
/// A short example program is below:
|
/// A short example program is below:
|
||||||
///
|
///
|
||||||
|
/// ```c++
|
||||||
/// int
|
/// int
|
||||||
/// main(int argc, char *argv[])
|
/// main(int argc, char *argv[])
|
||||||
/// {
|
/// {
|
||||||
/// std::string server = "service.example.com";
|
/// std::string server = "service.example.com";
|
||||||
/// unsigned int port = 1234;
|
/// unsigned int port = 1234;
|
||||||
///
|
///
|
||||||
/// auto flags = new scsl::Flags("example-client",
|
/// auto flags = new scsl::Flags("example-client",
|
||||||
/// "This interacts with the example.com service.");
|
/// "This interacts with the example.com service.");
|
||||||
/// flags->Register("-p", port, "server port");
|
/// flags->Register("-p", port, "server port");
|
||||||
/// flags->Register("-s", server, "hostname to connect to");
|
/// flags->Register("-s", server, "hostname to connect to");
|
||||||
///
|
///
|
||||||
/// auto status = flags->Parse(argc, argv);
|
/// auto status = flags->Parse(argc, argv);
|
||||||
/// if (status != ParseStatus::OK) {
|
/// if (status != ParseStatus::OK) {
|
||||||
/// std::cerr << "failed to parse flags: "
|
/// std::cerr << "failed to parse flags: "
|
||||||
/// << scsl::Flags::ParseStatusToString(status)
|
/// << scsl::Flags::ParseStatusToString(status)
|
||||||
/// << "\n";
|
/// << "\n";
|
||||||
/// exit(1);
|
/// exit(1);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// auto wasSet = flags->GetString("-s", server);
|
/// auto wasSet = flags->GetString("-s", server);
|
||||||
/// if (wasSet) {
|
/// if (wasSet) {
|
||||||
/// std::cout << "hostname override: " << server << "\n";
|
/// std::cout << "hostname override: " << server << "\n";
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// wasSet = flags->GetUnsignedInteger("-p", port);
|
/// wasSet = flags->GetUnsignedInteger("-p", port);
|
||||||
/// if (wasSet) {
|
/// if (wasSet) {
|
||||||
/// std::cout << "port override: " << port << "\n";
|
/// std::cout << "port override: " << port << "\n";
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// std::cout << "connecting to " << server << ":" << port << "\n";
|
/// std::cout << "connecting to " << server << ":" << port << "\n";
|
||||||
/// for (size_t i = 0; i < flags.NumArgs(); i++) {
|
/// for (size_t i = 0; i < flags.NumArgs(); i++) {
|
||||||
/// std::cout << "\tExecuting command " << flags.Arg(i) << "\n";
|
/// std::cout << "\tExecuting command " << flags.Arg(i) << "\n";
|
||||||
/// }
|
/// }
|
||||||
/// return 0;
|
/// return 0;
|
||||||
/// }
|
/// }
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
class Flags {
|
class Flags {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue