diff options
author | Greg Clayton <gclayton@apple.com> | 2010-09-18 03:37:20 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-09-18 03:37:20 +0000 |
commit | ed8a705cea596388aa0860c3e6fc327939716ce1 (patch) | |
tree | 6ecdf1264152d48f17722ba9bc1b323c43e914e2 /lldb/source/Interpreter/Options.cpp | |
parent | a6ba082cb63af874308938bda342b2e2a5737eaf (diff) | |
download | bcm5719-llvm-ed8a705cea596388aa0860c3e6fc327939716ce1.tar.gz bcm5719-llvm-ed8a705cea596388aa0860c3e6fc327939716ce1.zip |
General command line help cleanup:
- All single character options will now be printed together
- Changed all options that contains underscores to contain '-' instead
- Made the help come out a little flatter by showing the long and short
option on the same line.
- Modified the short character for "--ignore-count" options to "-i"
llvm-svn: 114265
Diffstat (limited to 'lldb/source/Interpreter/Options.cpp')
-rw-r--r-- | lldb/source/Interpreter/Options.cpp | 89 |
1 files changed, 76 insertions, 13 deletions
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 8e7f80896f3..57e68931443 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -402,6 +402,76 @@ Options::GenerateOptionUsage strm.Printf ("\n"); strm.Indent (name); + // First go through and print all options that take no arguments as + // a single string. If a command has "-a" "-b" and "-c", this will show + // up as [-abc] + + std::set<char> options; + std::set<char>::const_iterator options_pos, options_end; + bool first; + for (i = 0, first = true; i < num_options; ++i) + { + if (full_options_table[i].usage_mask & opt_set_mask) + { + // Add current option to the end of out_stream. + + if (full_options_table[i].required == true && + full_options_table[i].option_has_arg == no_argument) + { + options.insert (full_options_table[i].short_option); + } + } + } + + if (options.empty() == false) + { + // We have some required options with no arguments + strm.PutCString(" -"); + for (i=0; i<2; ++i) + for (options_pos = options.begin(), options_end = options.end(); + options_pos != options_end; + ++options_pos) + { + if (i==0 && ::isupper (*options_pos)) + continue; + if (i==1 && ::islower (*options_pos)) + continue; + strm << *options_pos; + } + } + + for (i = 0, options.clear(); i < num_options; ++i) + { + if (full_options_table[i].usage_mask & opt_set_mask) + { + // Add current option to the end of out_stream. + + if (full_options_table[i].required == false && + full_options_table[i].option_has_arg == no_argument) + { + options.insert (full_options_table[i].short_option); + } + } + } + + if (options.empty() == false) + { + // We have some required options with no arguments + strm.PutCString(" [-"); + for (i=0; i<2; ++i) + for (options_pos = options.begin(), options_end = options.end(); + options_pos != options_end; + ++options_pos) + { + if (i==0 && ::isupper (*options_pos)) + continue; + if (i==1 && ::islower (*options_pos)) + continue; + strm << *options_pos; + } + strm.PutChar(']'); + } + // First go through and print the required options (list them up front). for (i = 0; i < num_options; ++i) @@ -424,8 +494,6 @@ Options::GenerateOptionUsage full_options_table[i].short_option, full_options_table[i].argument_name); } - else - strm.Printf (" -%c", full_options_table[i].short_option); } } } @@ -446,8 +514,6 @@ Options::GenerateOptionUsage else if (full_options_table[i].option_has_arg == optional_argument) strm.Printf (" [-%c [%s]]", full_options_table[i].short_option, full_options_table[i].argument_name); - else - strm.Printf (" [-%c]", full_options_table[i].short_option); } } } @@ -455,8 +521,7 @@ Options::GenerateOptionUsage strm.Printf ("\n\n"); // Now print out all the detailed information about the various options: long form, short form and help text: - // -- long_name <argument> - // - short <argument> + // --long_name <argument> ( -short <argument> ) // help text // This variable is used to keep track of which options' info we've printed out, because some options can be in @@ -507,15 +572,13 @@ Options::GenerateOptionUsage strm.EOL(); strm.Indent (); - strm.Printf ("-%c ", full_options_table[i].short_option); + strm.Printf ("--%s", full_options_table[i].long_option); if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); - strm.Indent (); - strm.Printf ("--%s ", full_options_table[i].long_option); + strm.Printf (" %s", full_options_table[i].argument_name); + strm.Printf (" ( -%c", full_options_table[i].short_option); if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); + strm.Printf (" %s", full_options_table[i].argument_name); + strm.PutCString(" )\n"); strm.IndentMore (5); |