How To Use Gflags (formerly Google Commandline Flags)
Commandline flags are flags that users specify on the command line when they run an executable. In the command
fgrep -l -f /var/tmp/foo johannes brahms
-l
and -f /var/tmp/foo
are the two commandline flags. (johannes
and brahms
, which don't start with a dash, are commandline arguments.)
Typically, an application lists what flags the user is allowed to pass in, and what arguments they take -- in this example, -l
takes no argument, and -f
takes a string (in particular, a filename) as an argument. Users can use a library to help parse the commandline and store the flags in some data structure.
Gflags, the commandline flags library used within Google, differs from other libraries, such as getopt()
, in that flag definitions can be scattered around the source code, and not just listed in one place such as main()
. In practice, this means that a single source-code file will define and use flags that are meaningful to that file. Any application that links in that file will get the flags, and the gflags library will automatically handle that flag appropriately.
Read full article from How To Use Gflags (formerly Google Commandline Flags)
No comments:
Post a Comment