usage.h
Go to the documentation of this file.
00001 //
00002 //  Copyright 2019 The Abseil Authors.
00003 //
00004 // Licensed under the Apache License, Version 2.0 (the "License");
00005 // you may not use this file except in compliance with the License.
00006 // You may obtain a copy of the License at
00007 //
00008 //      https://www.apache.org/licenses/LICENSE-2.0
00009 //
00010 // Unless required by applicable law or agreed to in writing, software
00011 // distributed under the License is distributed on an "AS IS" BASIS,
00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 // See the License for the specific language governing permissions and
00014 // limitations under the License.
00015 
00016 #ifndef ABSL_FLAGS_INTERNAL_USAGE_H_
00017 #define ABSL_FLAGS_INTERNAL_USAGE_H_
00018 
00019 #include <iosfwd>
00020 #include <string>
00021 
00022 #include "absl/flags/declare.h"
00023 #include "absl/flags/internal/commandlineflag.h"
00024 #include "absl/strings/string_view.h"
00025 
00026 // --------------------------------------------------------------------
00027 // Usage reporting interfaces
00028 
00029 namespace absl {
00030 namespace flags_internal {
00031 
00032 // Sets the "usage" message to be used by help reporting routines.
00033 // For example:
00034 //  absl::SetProgramUsageMessage(
00035 //      absl::StrCat("This program does nothing.  Sample usage:\n", argv[0],
00036 //                   " <uselessarg1> <uselessarg2>"));
00037 // Do not include commandline flags in the usage: we do that for you!
00038 // Note: Calling SetProgramUsageMessage twice will trigger a call to std::exit.
00039 void SetProgramUsageMessage(absl::string_view new_usage_message);
00040 
00041 // Returns the usage message set by SetProgramUsageMessage().
00042 absl::string_view ProgramUsageMessage();
00043 
00044 // --------------------------------------------------------------------
00045 
00046 // The format to report the help messages in.
00047 enum class HelpFormat {
00048   kHumanReadable,
00049 };
00050 
00051 // Outputs the help message describing specific flag.
00052 void FlagHelp(std::ostream& out, const flags_internal::CommandLineFlag& flag,
00053               HelpFormat format = HelpFormat::kHumanReadable);
00054 
00055 // Produces the help messages for all flags matching the filter. A flag matches
00056 // the filter if it is defined in a file with a filename which includes
00057 // filter string as a substring. You can use '/' and '.' to restrict the
00058 // matching to a specific file names. For example:
00059 //   FlagsHelp(out, "/path/to/file.");
00060 // restricts help to only flags which resides in files named like:
00061 //  .../path/to/file.<ext>
00062 // for any extension 'ext'. If the filter is empty this function produces help
00063 // messages for all flags.
00064 void FlagsHelp(std::ostream& out, absl::string_view filter = {},
00065                HelpFormat format = HelpFormat::kHumanReadable);
00066 
00067 // --------------------------------------------------------------------
00068 
00069 // If any of the 'usage' related command line flags (listed on the bottom of
00070 // this file) has been set this routine produces corresponding help message in
00071 // the specified output stream and returns:
00072 //  0 - if "version" or "only_check_flags" flags were set and handled.
00073 //  1 - if some other 'usage' related flag was set and handled.
00074 // -1 - if no usage flags were set on a commmand line.
00075 // Non negative return values are expected to be used as an exit code for a
00076 // binary.
00077 int HandleUsageFlags(std::ostream& out);
00078 
00079 }  // namespace flags_internal
00080 }  // namespace absl
00081 
00082 ABSL_DECLARE_FLAG(bool, help);
00083 ABSL_DECLARE_FLAG(bool, helpfull);
00084 ABSL_DECLARE_FLAG(bool, helpshort);
00085 ABSL_DECLARE_FLAG(bool, helppackage);
00086 ABSL_DECLARE_FLAG(bool, version);
00087 ABSL_DECLARE_FLAG(bool, only_check_args);
00088 ABSL_DECLARE_FLAG(std::string, helpon);
00089 ABSL_DECLARE_FLAG(std::string, helpmatch);
00090 
00091 #endif  // ABSL_FLAGS_INTERNAL_USAGE_H_


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:16