X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fexperimental%2FNestedCommandLineApp.h;h=2421034162ad68ce6b4fca957d47eec06703771c;hb=a1d0f15abbfdf3fc34bdfcfa6eb771f9ddef55a3;hp=aa9d061f910f127021127d6b3d124227caf34c9b;hpb=5532f19f7b604a9b12c79a1d0a4fe3b0ff74f3d1;p=folly.git diff --git a/folly/experimental/NestedCommandLineApp.h b/folly/experimental/NestedCommandLineApp.h index aa9d061f..24210341 100644 --- a/folly/experimental/NestedCommandLineApp.h +++ b/folly/experimental/NestedCommandLineApp.h @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FOLLY_NESTEDCOMMANDLINEAPP_H_ -#define FOLLY_NESTEDCOMMANDLINEAPP_H_ +#pragma once #include #include @@ -26,10 +25,10 @@ namespace folly { /** * Exception that commands may throw to force the program to exit cleanly - * with a non-zero exit code. NestedCommandLineApp::run() catches this and + * with a given exit code. NestedCommandLineApp::run() catches this and * makes run() print the given message on stderr (followed by a newline, unless - * empty), and return the exit code. (Other exceptions will propagate out of - * run()) + * empty; the message is only allowed when exiting with a non-zero status), and + * return the exit code. (Other exceptions will propagate out of run()) */ class ProgramExit : public std::runtime_error { public: @@ -68,6 +67,8 @@ class NestedCommandLineApp { explicit NestedCommandLineApp( std::string programName = std::string(), std::string version = std::string(), + std::string programHeading = std::string(), + std::string programHelpFooter = std::string(), InitFunction initFunction = InitFunction()); /** @@ -114,6 +115,11 @@ class NestedCommandLineApp { * Run the command and return; the return code is 0 on success or * non-zero on error, so it is idiomatic to call this at the end of main(): * return app.run(argc, argv); + * + * On successful exit, run() will check for errors on stdout (and flush + * it) to help command-line applications that need to write to stdout + * (failing to write to stdout is an error). If there is an error on stdout, + * we'll print a helpful message on stderr and return an error status (1). */ int run(int argc, const char* const argv[]); int run(const std::vector& args); @@ -138,6 +144,8 @@ class NestedCommandLineApp { const std::vector& args); std::string programName_; + std::string programHeading_; + std::string programHelpFooter_; std::string version_; InitFunction initFunction_; boost::program_options::options_description globalOptions_; @@ -145,6 +153,4 @@ class NestedCommandLineApp { std::map aliases_; }; -} // namespaces - -#endif /* FOLLY_NESTEDCOMMANDLINEAPP_H_ */ +} // namespace folly