aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/small/modchooser.h
diff options
context:
space:
mode:
authordimdim11 <dimdim11@yandex-team.com>2023-06-07 00:12:42 +0300
committerdimdim11 <dimdim11@yandex-team.com>2023-06-07 00:12:42 +0300
commit5dfc708d4bbd53d9fbd627d7753f4c3a27cda532 (patch)
treee65fa658724da936a59524753686404c0682654d /library/cpp/getopt/small/modchooser.h
parentd7618ef587053f2eb7d20f0b2d89709e69009c1b (diff)
downloadydb-5dfc708d4bbd53d9fbd627d7753f4c3a27cda532.tar.gz
getopt: print help either to Cerr or Cout, configuring by option
Fix arc help output
Diffstat (limited to 'library/cpp/getopt/small/modchooser.h')
-rw-r--r--library/cpp/getopt/small/modchooser.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/library/cpp/getopt/small/modchooser.h b/library/cpp/getopt/small/modchooser.h
index 987353e3d1..5ed64310c5 100644
--- a/library/cpp/getopt/small/modchooser.h
+++ b/library/cpp/getopt/small/modchooser.h
@@ -80,6 +80,11 @@ public:
//! Set short command representation in Usage block
void SetPrintShortCommandInUsage(bool printShortCommandInUsage);
+ //! Help can be printed either to stdout and stderr. If set to false, then "--help" will be printed to stdout
+ void SetHelpAlwaysToStdErr(bool helpAlwaysToStdErr) {
+ HelpAlwaysToStdErr = helpAlwaysToStdErr;
+ }
+
void DisableSvnRevisionOption();
void AddCompletions(TString progName, const TString& name = "completion", bool hidden = false, bool noCompletion = false);
@@ -100,7 +105,7 @@ public:
//! Run appropriate mode. Same as Run(const int, const char**)
int Run(const TVector<TString>& argv) const;
- void PrintHelp(const TString& progName) const;
+ void PrintHelp(const TString& progName, bool toStdErr = false) const;
struct TMode {
TString Name;
@@ -169,6 +174,16 @@ private:
//! Mode that generates completions
THolder<TMainClass> CompletionsGenerator;
+
+ /*! Help message always output to StdErr
+ *
+ * If an error occurs, the help information will be printed to stderr regardless of the settings.
+ * Setting below for success cases (return code == 0) like "./bin --help".
+ * In this case by default help will be printed to stderr,
+ * but it can be overridden by setting "HelpAlwaysToStdErr" to false see SetHelpAlwaysToStdErr() above,
+ * then help message will be printed to stdout
+ */
+ bool HelpAlwaysToStdErr{true};
};
//! Mode class that allows introspecting its console arguments.