Commit 290da389 authored by Craig Silverstein's avatar Craig Silverstein

Wed Mar 28 12:15:56 2007 Google Inc. <opensource@google.com>

	* google-gflags: version 0.3
	* python portability fix: use popen instead of subprocess (csilvers)
	* Add is_default to CommandLineFlagInfo (pchien)
	* Make docs a bit prettier (csilvers)
	* Actually include the python files in the distribution! :-/ (csilvers)


git-svn-id: https://gflags.googlecode.com/svn/trunk@11 6586e3c6-dcc4-952a-343f-ff74eb82781d
parent 573580dc
...@@ -12,3 +12,11 @@ Mon Jan 22 15:33:06 2007 Google Inc. <opensource@google.com> ...@@ -12,3 +12,11 @@ Mon Jan 22 15:33:06 2007 Google Inc. <opensource@google.com>
* google-gflags: version 0.2 * google-gflags: version 0.2
* added support for python commandlineflags, as well as c++ * added support for python commandlineflags, as well as c++
* gflags2man, a script to turn flags into a man page (dchristian) * gflags2man, a script to turn flags into a man page (dchristian)
Wed Mar 28 12:15:56 2007 Google Inc. <opensource@google.com>
* google-gflags: version 0.3
* python portability fix: use popen instead of subprocess (csilvers)
* Add is_default to CommandLineFlagInfo (pchien)
* Make docs a bit prettier (csilvers)
* Actually include the python files in the distribution! :-/ (csilvers)
...@@ -58,6 +58,13 @@ noinst_SCRIPTS += src/gflags_unittest.sh ...@@ -58,6 +58,13 @@ noinst_SCRIPTS += src/gflags_unittest.sh
gflags_unittest_sh: gflags_unittest gflags_unittest_sh: gflags_unittest
$(top_srcdir)/src/gflags_unittest.sh $(PWD)/$< $(top_srcdir)/src/gflags_unittest.sh $(PWD)/$<
# These aren't part of the c++ source, but we want them to be distributed
PYTHON = python/setup.py \
python/gflags.py \
python/gflags2man.py \
python/gflags_unittest.py
## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS ## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
...@@ -74,4 +81,4 @@ deb: dist-gzip packages/deb.sh packages/deb/* ...@@ -74,4 +81,4 @@ deb: dist-gzip packages/deb.sh packages/deb/*
libtool: $(LIBTOOL_DEPS) libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status --recheck $(SHELL) ./config.status --recheck
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \ EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
libtool $(SCRIPTS) libtool $(SCRIPTS) $(PYTHON)
...@@ -260,8 +260,15 @@ gflags_unittest_SOURCES = $(googleinclude_HEADERS) src/config.h \ ...@@ -260,8 +260,15 @@ gflags_unittest_SOURCES = $(googleinclude_HEADERS) src/config.h \
gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS) gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS) gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS)
# These aren't part of the c++ source, but we want them to be distributed
PYTHON = python/setup.py \
python/gflags.py \
python/gflags2man.py \
python/gflags_unittest.py
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \ EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
libtool $(SCRIPTS) libtool $(SCRIPTS) $(PYTHON)
all: all-am all: all-am
...@@ -586,7 +593,7 @@ check-TESTS: $(TESTS) ...@@ -586,7 +593,7 @@ check-TESTS: $(TESTS)
distdir: $(DISTFILES) distdir: $(DISTFILES)
$(am__remove_distdir) $(am__remove_distdir)
mkdir $(distdir) mkdir $(distdir)
$(mkdir_p) $(distdir)/doc $(distdir)/packages $(distdir)/packages/rpm $(distdir)/src $(distdir)/src/google $(mkdir_p) $(distdir)/doc $(distdir)/packages $(distdir)/packages/rpm $(distdir)/python $(distdir)/src $(distdir)/src/google
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \ list='$(DISTFILES)'; for file in $$list; do \
......
...@@ -6741,12 +6741,10 @@ AC_DEFUN([AX_C___ATTRIBUTE__], [ ...@@ -6741,12 +6741,10 @@ AC_DEFUN([AX_C___ATTRIBUTE__], [
AC_MSG_CHECKING(for __attribute__) AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [ AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE( AC_TRY_COMPILE(
[#include <stdlib.h>], [#include <stdlib.h>
[static void foo(void) __attribute__ ((unused)); static void foo(void) __attribute__ ((unused));
static void void foo(void) { exit(1); }],
foo(void) { [],
exit(1);
}],
ac_cv___attribute__=yes, ac_cv___attribute__=yes,
ac_cv___attribute__=no ac_cv___attribute__=no
)]) )])
......
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for gflags 0.2. # Generated by GNU Autoconf 2.59 for gflags 0.3.
# #
# Report bugs to <opensource@google.com>. # Report bugs to <opensource@google.com>.
# #
...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='gflags' PACKAGE_NAME='gflags'
PACKAGE_TARNAME='gflags' PACKAGE_TARNAME='gflags'
PACKAGE_VERSION='0.2' PACKAGE_VERSION='0.3'
PACKAGE_STRING='gflags 0.2' PACKAGE_STRING='gflags 0.3'
PACKAGE_BUGREPORT='opensource@google.com' PACKAGE_BUGREPORT='opensource@google.com'
ac_unique_file="README" ac_unique_file="README"
...@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then ...@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures gflags 0.2 to adapt to many kinds of systems. \`configure' configures gflags 0.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1020,7 +1020,7 @@ fi ...@@ -1020,7 +1020,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of gflags 0.2:";; short | recursive ) echo "Configuration of gflags 0.3:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1163,7 +1163,7 @@ fi ...@@ -1163,7 +1163,7 @@ fi
test -n "$ac_init_help" && exit 0 test -n "$ac_init_help" && exit 0
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
gflags configure 0.2 gflags configure 0.3
generated by GNU Autoconf 2.59 generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003 Free Software Foundation, Inc.
...@@ -1177,7 +1177,7 @@ cat >&5 <<_ACEOF ...@@ -1177,7 +1177,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by gflags $as_me 0.2, which was It was created by gflags $as_me 0.3, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -1823,7 +1823,7 @@ fi ...@@ -1823,7 +1823,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='gflags' PACKAGE='gflags'
VERSION='0.2' VERSION='0.3'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -19798,14 +19798,12 @@ cat confdefs.h >>conftest.$ac_ext ...@@ -19798,14 +19798,12 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
#include <stdlib.h> #include <stdlib.h>
static void foo(void) __attribute__ ((unused));
void foo(void) { exit(1); }
int int
main () main ()
{ {
static void foo(void) __attribute__ ((unused));
static void
foo(void) {
exit(1);
}
; ;
return 0; return 0;
} }
...@@ -21158,7 +21156,7 @@ _ASBOX ...@@ -21158,7 +21156,7 @@ _ASBOX
} >&5 } >&5
cat >&5 <<_CSEOF cat >&5 <<_CSEOF
This file was extended by gflags $as_me 0.2, which was This file was extended by gflags $as_me 0.3, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -21221,7 +21219,7 @@ _ACEOF ...@@ -21221,7 +21219,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
gflags config.status 0.2 gflags config.status 0.3
configured by $0, generated by GNU Autoconf 2.59, configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# make sure we're interpreted by some minimal autoconf # make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT(gflags, 0.2, opensource@google.com) AC_INIT(gflags, 0.3, opensource@google.com)
# The argument here is just something that should be in the current directory # The argument here is just something that should be in the current directory
# (for sanity checking) # (for sanity checking)
AC_CONFIG_SRCDIR(README) AC_CONFIG_SRCDIR(README)
......
body {
background-color: #ffffff;
color: black;
margin-right: 1in;
margin-left: 1in;
}
h1, h2, h3, h4, h5, h6 {
color: #3366ff;
font-family: sans-serif;
}
@media print {
/* Darker version for printing */
h1, h2, h3, h4, h5, h6 {
color: #000080;
font-family: helvetica, sans-serif;
}
}
h1 {
text-align: center;
font-size: 18pt;
}
h2 {
margin-left: -0.5in;
}
h3 {
margin-left: -0.25in;
}
h4 {
margin-left: -0.125in;
}
hr {
margin-left: -1in;
}
/* Definition lists: definition term bold */
dt {
font-weight: bold;
}
address {
text-align: right;
}
/* Use the <code> tag for bits of code and <var> for variables and objects. */
code,pre,samp,var {
color: #006000;
}
/* Use the <file> tag for file and directory paths and names. */
file {
color: #905050;
font-family: monospace;
}
/* Use the <kbd> tag for stuff the user should type. */
kbd {
color: #600000;
}
div.note p {
float: right;
width: 3in;
margin-right: 0%;
padding: 1px;
border: 2px solid #6060a0;
background-color: #fffff0;
}
UL.nobullets {
list-style-type: none;
list-style-image: none;
margin-left: -1em;
}
/*
body:after {
content: "Google Confidential";
}
*/
/* pretty printing styles. See prettify.js */
.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
pre.prettyprint { padding: 2px; border: 1px solid #888; }
.embsrc { background: #eee; }
@media print {
.str { color: #060; }
.kwd { color: #006; font-weight: bold; }
.com { color: #600; font-style: italic; }
.typ { color: #404; font-weight: bold; }
.lit { color: #044; }
.pun { color: #440; }
.pln { color: #000; }
.tag { color: #006; font-weight: bold; }
.atn { color: #404; }
.atv { color: #060; }
}
/* Table Column Headers */
.hdr {
color: #006;
font-weight: bold;
background-color: #dddddd; }
.hdr2 {
color: #006;
background-color: #eeeeee; }
\ No newline at end of file
usr/lib
usr/include
usr/include/google
usr/include/google/*
usr/lib/lib*.so
usr/lib/lib*.a
usr/lib/*.la
debian/tmp/usr/include/google/*
debian/tmp/usr/lib/lib*.so
debian/tmp/usr/lib/lib*.a
debian/tmp/usr/lib/*.la
usr/lib/lib*.so.*
debian/tmp/usr/lib/lib*.so.*
...@@ -52,7 +52,6 @@ import re ...@@ -52,7 +52,6 @@ import re
import sys import sys
import stat import stat
import time import time
import subprocess
import gflags import gflags
...@@ -189,29 +188,18 @@ class ProgramInfo(object): ...@@ -189,29 +188,18 @@ class ProgramInfo(object):
logging.info('Running: %s %s </dev/null 2>&1' logging.info('Running: %s %s </dev/null 2>&1'
% (self.executable, FLAGS.help_flag)) % (self.executable, FLAGS.help_flag))
# --help output is often routed to stderr, so we re-direct that to # --help output is often routed to stderr, so we combine with stdout.
# stdout. Re-direct stdin to /dev/null to encourage programs that # Re-direct stdin to /dev/null to encourage programs that
# don't understand --help to exit. # don't understand --help to exit.
try: (child_stdin, child_stdout_and_stderr) = os.popen4(
runstate = subprocess.Popen( [self.executable, FLAGS.help_flag])
[self.executable, FLAGS.help_flag], child_stdin.close() # '</dev/null'
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, self.output = child_stdout_and_stderr.readlines()
stdin=open('/dev/null', 'r')) child_stdout_and_stderr.close()
except OSError, msg:
logging.error('Error executing "%s": %s' % (self.name, msg))
return 0
# read output progressively so the pipe doesn't fill up (fileutil).
self.output = runstate.stdout.readlines()
status = runstate.wait()
logging.debug('Program exited with %s' % status)
output = runstate.communicate()[0]
if output:
self.output = output.splitlines()
if len(self.output) < _MIN_VALID_USAGE_MSG: if len(self.output) < _MIN_VALID_USAGE_MSG:
logging.error( logging.error('Error: "%s %s" returned only %d lines: %s'
'Error: "%s %s" returned %d and only %d lines: %s' % (self.name, FLAGS.help_flag,
% (self.name, FLAGS.help_flag, status, len(self.output), output)) len(self.output), self.output))
return 0 return 0
return 1 return 1
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
from distutils.core import setup from distutils.core import setup
setup(name='gflags', setup(name='gflags',
version='0.2', version='0.3',
description='Google Commandline Flags Module', description='Google Commandline Flags Module',
license='BSD', license='BSD',
author='Google Inc.', author='Google Inc.',
......
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Namespace for Google classes */
#undef GOOGLE_NAMESPACE
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* define if the compiler implements namespaces */
#undef HAVE_NAMESPACES
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* the namespace where STL code like vector<> is defined */
#undef STL_NAMESPACE
/* Version number of package */
#undef VERSION
/* Stops putting the code inside the Google namespace */
#undef _END_GOOGLE_NAMESPACE_
/* Puts following code inside the Google namespace */
#undef _START_GOOGLE_NAMESPACE_
...@@ -316,7 +316,7 @@ class CommandLineFlag { ...@@ -316,7 +316,7 @@ class CommandLineFlag {
string default_value() const { return defvalue_->ToString(); } string default_value() const { return defvalue_->ToString(); }
const char* type_name() const { return defvalue_->TypeName(); } const char* type_name() const { return defvalue_->TypeName(); }
void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result) const; void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result);
private: private:
friend class FlagRegistry; // for SetFlagLocked() friend class FlagRegistry; // for SetFlagLocked()
...@@ -386,13 +386,15 @@ const char* CommandLineFlag::CleanFileName() const { ...@@ -386,13 +386,15 @@ const char* CommandLineFlag::CleanFileName() const {
} }
void CommandLineFlag::FillCommandLineFlagInfo( void CommandLineFlag::FillCommandLineFlagInfo(
CommandLineFlagInfo* result) const { CommandLineFlagInfo* result) {
result->name = name(); result->name = name();
result->type = type_name(); result->type = type_name();
result->description = help(); result->description = help();
result->current_value = current_value(); result->current_value = current_value();
result->default_value = default_value(); result->default_value = default_value();
result->filename = CleanFileName(); result->filename = CleanFileName();
UpdateModifiedBit();
result->is_default = !modified_;
} }
void CommandLineFlag::UpdateModifiedBit() { void CommandLineFlag::UpdateModifiedBit() {
...@@ -1141,6 +1143,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( ...@@ -1141,6 +1143,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// GetCommandLineOption() // GetCommandLineOption()
// GetCommandLineFlagInfo() // GetCommandLineFlagInfo()
// GetCommandLineFlagInfoOrDie()
// SetCommandLineOption() // SetCommandLineOption()
// SetCommandLineOptionWithMode() // SetCommandLineOptionWithMode()
// The programmatic way to set a flag's value, using a string // The programmatic way to set a flag's value, using a string
...@@ -1196,6 +1199,15 @@ bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT) { ...@@ -1196,6 +1199,15 @@ bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT) {
} }
} }
CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name) {
CommandLineFlagInfo info;
if (!GetCommandLineFlagInfo(name, &info)) {
fprintf(stderr, "FATAL ERROR: flag name '%s' doesn't exit", name);
commandlineflags_exitfunc(1); // almost certainly exit()
}
return info;
}
string SetCommandLineOptionWithMode(const char* name, const char* value, string SetCommandLineOptionWithMode(const char* name, const char* value,
FlagSettingMode set_mode) { FlagSettingMode set_mode) {
string result; string result;
......
...@@ -860,6 +860,45 @@ TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) { ...@@ -860,6 +860,45 @@ TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) {
EXPECT_EQ(false, r); EXPECT_EQ(false, r);
} }
TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndIsDefault) {
CommandLineFlagInfo info;
info = GetCommandLineFlagInfoOrDie("test_int32");
EXPECT_EQ("test_int32", info.name);
EXPECT_EQ("int32", info.type);
EXPECT_EQ("", info.description);
EXPECT_EQ("-1", info.default_value);
EXPECT_EQ(true, info.is_default);
info = GetCommandLineFlagInfoOrDie("test_bool");
EXPECT_EQ("test_bool", info.name);
EXPECT_EQ("bool", info.type);
EXPECT_EQ("tests bool-ness", info.description);
EXPECT_EQ("false", info.default_value);
EXPECT_EQ(true, info.is_default);
}
TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndWasAssigned) {
FLAGS_test_int32 = 400;
CommandLineFlagInfo info;
info = GetCommandLineFlagInfoOrDie("test_int32");
EXPECT_EQ("test_int32", info.name);
EXPECT_EQ("int32", info.type);
EXPECT_EQ("", info.description);
EXPECT_EQ("-1", info.default_value);
EXPECT_EQ(false, info.is_default);
FLAGS_test_bool = true;
info = GetCommandLineFlagInfoOrDie("test_bool");
EXPECT_EQ("test_bool", info.name);
EXPECT_EQ("bool", info.type);
EXPECT_EQ("tests bool-ness", info.description);
EXPECT_EQ("false", info.default_value);
EXPECT_EQ(false, info.is_default);
}
TEST(GetCommandLineFlagInfoOrDieTest, FlagDoesNotExist) {
EXPECT_DEATH(GetCommandLineFlagInfoOrDie("test_int3210"),
".*: flag test_int3210 does not exist");
}
// These are lightly tested because they're deprecated. Basically, // These are lightly tested because they're deprecated. Basically,
// the tests are meant to cover how existing users use these functions, // the tests are meant to cover how existing users use these functions,
......
...@@ -112,6 +112,7 @@ struct CommandLineFlagInfo { ...@@ -112,6 +112,7 @@ struct CommandLineFlagInfo {
std::string current_value; // the current value, as a string std::string current_value; // the current value, as a string
std::string default_value; // the default value, as a string std::string default_value; // the default value, as a string
std::string filename; // 'cleaned' version of filename holding the flag std::string filename; // 'cleaned' version of filename holding the flag
bool is_default; // true if the flag has default value
}; };
extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT); extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
...@@ -140,11 +141,19 @@ extern const char* ProgramUsage(); // string set by SetUsageMessage() ...@@ -140,11 +141,19 @@ extern const char* ProgramUsage(); // string set by SetUsageMessage()
// OUTPUT is set to the flag's value, or unchanged if we return false. // OUTPUT is set to the flag's value, or unchanged if we return false.
extern bool GetCommandLineOption(const char* name, std::string* OUTPUT, extern bool GetCommandLineOption(const char* name, std::string* OUTPUT,
bool *is_default_value = NULL); bool *is_default_value = NULL);
// Return true iff the flagname was found. OUTPUT is set to the flag's // Return true iff the flagname was found. OUTPUT is set to the flag's
// CommandLineFlagInfo or unchanged if we return false. // CommandLineFlagInfo or unchanged if we return false.
extern bool GetCommandLineFlagInfo(const char* name, extern bool GetCommandLineFlagInfo(const char* name,
CommandLineFlagInfo* OUTPUT); CommandLineFlagInfo* OUTPUT);
// Return the CommandLineFlagInfo of the flagname.
// assertion failure if the flagname was not found.
//
// Example to check if a flag has default value:
// if (GetCommandLineFlagInfoOrDie("foo").is_default)
extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
enum FlagSettingMode { enum FlagSettingMode {
// update the flag's value (can call this multiple times). // update the flag's value (can call this multiple times).
SET_FLAGS_VALUE, SET_FLAGS_VALUE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment