Cleanup example program in Flag docs.

This commit is contained in:
Kyle Isom 2023-10-16 17:54:35 -07:00
parent a0cd2ca866
commit b7584b06cc
1 changed files with 19 additions and 17 deletions

36
Flag.h
View File

@ -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: