usage.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 The Abseil Authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef ABSL_FLAGS_INTERNAL_USAGE_H_
17 #define ABSL_FLAGS_INTERNAL_USAGE_H_
18 
19 #include <iosfwd>
20 #include <string>
21 
22 #include "absl/flags/declare.h"
25 
26 // --------------------------------------------------------------------
27 // Usage reporting interfaces
28 
29 namespace absl {
30 namespace flags_internal {
31 
32 // Sets the "usage" message to be used by help reporting routines.
33 // For example:
34 // absl::SetProgramUsageMessage(
35 // absl::StrCat("This program does nothing. Sample usage:\n", argv[0],
36 // " <uselessarg1> <uselessarg2>"));
37 // Do not include commandline flags in the usage: we do that for you!
38 // Note: Calling SetProgramUsageMessage twice will trigger a call to std::exit.
39 void SetProgramUsageMessage(absl::string_view new_usage_message);
40 
41 // Returns the usage message set by SetProgramUsageMessage().
43 
44 // --------------------------------------------------------------------
45 
46 // The format to report the help messages in.
47 enum class HelpFormat {
49 };
50 
51 // Outputs the help message describing specific flag.
52 void FlagHelp(std::ostream& out, const flags_internal::CommandLineFlag& flag,
54 
55 // Produces the help messages for all flags matching the filter. A flag matches
56 // the filter if it is defined in a file with a filename which includes
57 // filter string as a substring. You can use '/' and '.' to restrict the
58 // matching to a specific file names. For example:
59 // FlagsHelp(out, "/path/to/file.");
60 // restricts help to only flags which resides in files named like:
61 // .../path/to/file.<ext>
62 // for any extension 'ext'. If the filter is empty this function produces help
63 // messages for all flags.
64 void FlagsHelp(std::ostream& out, absl::string_view filter = {},
66 
67 // --------------------------------------------------------------------
68 
69 // If any of the 'usage' related command line flags (listed on the bottom of
70 // this file) has been set this routine produces corresponding help message in
71 // the specified output stream and returns:
72 // 0 - if "version" or "only_check_flags" flags were set and handled.
73 // 1 - if some other 'usage' related flag was set and handled.
74 // -1 - if no usage flags were set on a commmand line.
75 // Non negative return values are expected to be used as an exit code for a
76 // binary.
77 int HandleUsageFlags(std::ostream& out);
78 
79 } // namespace flags_internal
80 } // namespace absl
81 
82 ABSL_DECLARE_FLAG(bool, help);
83 ABSL_DECLARE_FLAG(bool, helpfull);
84 ABSL_DECLARE_FLAG(bool, helpshort);
85 ABSL_DECLARE_FLAG(bool, helppackage);
87 ABSL_DECLARE_FLAG(bool, only_check_args);
88 ABSL_DECLARE_FLAG(std::string, helpon);
89 ABSL_DECLARE_FLAG(std::string, helpmatch);
90 
91 #endif // ABSL_FLAGS_INTERNAL_USAGE_H_
ABSL_DECLARE_FLAG(bool, help)
void SetProgramUsageMessage(absl::string_view new_usage_message)
Definition: usage.cc:290
void FlagHelp(std::ostream &out, const flags_internal::CommandLineFlag &flag, HelpFormat format)
Definition: usage.cc:315
uint32_t version
Definition: graphcycles.cc:278
void FlagsHelp(std::ostream &out, absl::string_view filter, HelpFormat format)
Definition: usage.cc:324
Definition: algorithm.h:29
std::string format(const std::string &, const time_point< seconds > &, const femtoseconds &, const time_zone &)
int HandleUsageFlags(std::ostream &out)
Definition: usage.cc:334
absl::string_view ProgramUsageMessage()
Definition: usage.cc:305
char * out
Definition: mutex.h:1013


abseil_cpp
Author(s):
autogenerated on Mon Feb 28 2022 21:31:21