[PATCH] D21485: [cl] Teach cl to support the notion of sub commands (e.g. "git checkout <foo>")

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 16:28:40 PDT 2016


zturner created this revision.
zturner added reviewers: beanz, chandlerc, rnk.
zturner added a subscriber: llvm-commits.

This patch improves cl to support sub commands.  For example, "git checkout", "git status", etc where each subcommand has an unrelated set of options.

An example of how to use this new functionality is included in this patch where the `llvm-pdbdump` tool is updated to use this new functionality.  If / when this patch is accepted, I will only submit with the changes to `cl`, and then submit the changes to `llvm-pdbdump` as a followup.  It's only included here as an example.

Any code which was previously written against cl will continue to work unmodified.  If you don't specify a subcommand for an option, commands go into the "top level" subcommand, which is searched when no subcommand is specified.

There is another special subcommand called `AllSubcommands` which, when specified, will inject an option into every sub command.  This is useful, for example, to make `foo.exe --help` and `foo.exe command --help` both work and do the right thing.

options can also have multiple subcommands, so that the same option will appear in multiple subcommands.

Help output is updated as well to print info about supported subcommands, and also to print the list of options for individual subcommands.

Not sure who to include as a reviewer, feel free to add others as appropriate.

http://reviews.llvm.org/D21485

Files:
  include/llvm/Support/CommandLine.h
  lib/Support/CommandLine.cpp
  test/DebugInfo/PDB/DIA/pdbdump-flags.test
  test/DebugInfo/PDB/DIA/pdbdump-linenumbers.test
  test/DebugInfo/PDB/DIA/pdbdump-symbol-format.test
  test/DebugInfo/PDB/pdbdump-headers.test
  test/DebugInfo/PDB/pdbdump-yaml.test
  test/tools/llvm-pdbdump/class-layout.test
  test/tools/llvm-pdbdump/enum-layout.test
  test/tools/llvm-pdbdump/load-address.test
  test/tools/llvm-pdbdump/regex-filter.test
  tools/llvm-pdbdump/ClassDefinitionDumper.cpp
  tools/llvm-pdbdump/EnumDumper.cpp
  tools/llvm-pdbdump/LLVMOutputStyle.cpp
  tools/llvm-pdbdump/LinePrinter.cpp
  tools/llvm-pdbdump/TypeDumper.cpp
  tools/llvm-pdbdump/VariableDumper.cpp
  tools/llvm-pdbdump/YAMLOutputStyle.cpp
  tools/llvm-pdbdump/llvm-pdbdump.cpp
  tools/llvm-pdbdump/llvm-pdbdump.h
  unittests/Support/CommandLineTest.cpp
  unittests/Support/ProgramTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21485.61142.patch
Type: text/x-patch
Size: 76586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160617/62139930/attachment.bin>


More information about the llvm-commits mailing list