Jochen Wilhelmy
2010-Oct-09 11:59 UTC
[LLVMdev] how to disable command line options in llvm libs
Hi! I'd like to use llvm::cl as it seems quite easy to use, but there currently seems to be a major drawback: if I do -help then all options from all llvm libs that I have included are shown, but I just have an input file and output file to specify. Is it possible to disable the existing options? For example by assigning each option a flag. One flag could be for llvm options, another for hidden llvm options and one for my application (if llvm uses 2 there are 30 left ;-). These flags could replace the hidden and "really hidden" states. Options would be hidden if their flag is not set in an int passed to cl::ParseCommandLineOptions (perhaps 2 sets of flags, one for -help and one for -help-hidden). Another possibility would be to specify the list of registered options explicitly for each of my options (default is the static one in CommandLine.cpp) and this could be passed to cl::ParseCommandLineOptions. -Jochen
Michael Spencer
2010-Oct-09 15:13 UTC
[LLVMdev] how to disable command line options in llvm libs
On Sat, Oct 9, 2010 at 7:59 AM, Jochen Wilhelmy <j.wilhelmy at arcor.de> wrote:> Hi! > > I'd like to use llvm::cl as it seems quite easy to use, but there > currently seems to be > a major drawback: if I do -help then all options from all llvm libs that > I have included > are shown, but I just have an input file and output file to specify.I've always found this incredibly annoying, as have others. I *think* this is a "patches welcome" problem.> Is it possible to > disable the existing options? For example by assigning each option a flag. > One flag could be for llvm options, another for hidden llvm options and one > for my application (if llvm uses 2 there are 30 left ;-). These flags > could replace the hidden and > "really hidden" states. Options would be hidden if their flag is not set > in an int passed to > cl::ParseCommandLineOptions (perhaps 2 sets of flags, one for -help and > one for -help-hidden).It is not currently possible, but this is one solution.> Another possibility would be to specify the list of registered options > explicitly for > each of my options (default is the static one in CommandLine.cpp) and this > could be passed to cl::ParseCommandLineOptions. > > -JochenI think what we really need is what quite a few other tools (gdb and git come to mind) do. We should provide help/argument namespaces with a way to control the output. There are really two cases I can think of here. The first is tools like opt and bugpoint where there are a bunch of useful options. In this case it would be nice to directly show the options that are tool specific, and then show categories for other options pulled in from the library. The second case is tools like llvm-as and the one you are writing that link to the llvm passes, but don't care about the other options because they have _no_ effect on the behavior of the program. In this case You should be able to completely disable options that have no effect on output. With this you would end up with output such as: % opt -help OVERVIEW: llvm .bc -> .bc modular optimizer and analysis printer USAGE: opt [options] <input bitcode file> OPTIONS: Common Options: -O<n> -blah blah blah -S -analyze -<pass> - run <pass> see -help passes for a list of passes. -help [category] - Show help for category ... Option Categories: passes stats debug output ... One could then type: % opt -help passes And get the long list of passes. It would also be nice to make all the llvm tools use the same option names when they mean the same thing. For instance some tools use -mtriple and others use -triple. - Michael Spencer
Jochen Wilhelmy
2010-Oct-09 18:49 UTC
[LLVMdev] how to disable command line options in llvm libs
> I think what we really need is what quite a few other tools (gdb and > git come to mind) do. We should provide help/argument namespaces with > a way to control the output. >This sounds reasonable. Assigning a namespace to each option and then some global control of what to do with the namespaces (show, hide, "sub-menu" with -help <namespace>). for me and my two options I now use boost::program_options -Jochen