[Lldb-commits] [PATCH] D117004: [lldb] Don't print "Command Options Usage:" for an alias with no options
David Spickett via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 11 03:09:48 PST 2022
DavidSpickett created this revision.
Herald added a subscriber: jeroen.dobbelaere.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
"shell" is an alias to "platform shell -h --". Previously you would get this
help text:
(lldb) help shell
Run a shell command on the host. Expects 'raw' input (see 'help raw-input'.)
Syntax: shell <shell-command>
Command Options Usage:
'shell' is an abbreviation for 'platform shell -h --'
Since the code doesn't handle the base command having options
but the alias removing them. With these changes you get:
(lldb) help shell
Run a shell command on the host. Expects 'raw' input (see 'help raw-input'.)
Syntax: shell <shell-command>
'shell' is an abbreviation for 'platform shell -h --'
Note that we already handle a non-alias command having no options,
for example "quit":
(lldb) help quit
Quit the LLDB debugger.
Syntax: quit [exit-code]
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117004
Files:
lldb/source/Interpreter/Options.cpp
lldb/test/API/commands/platform/basic/TestPlatformCommand.py
Index: lldb/test/API/commands/platform/basic/TestPlatformCommand.py
===================================================================
--- lldb/test/API/commands/platform/basic/TestPlatformCommand.py
+++ lldb/test/API/commands/platform/basic/TestPlatformCommand.py
@@ -20,10 +20,12 @@
self.runCmd("help platform")
@no_debug_info_test
- def test_help_platform(self):
+ def test_help_shell_alias(self):
self.expect("help shell", substrs=["Run a shell command on the host.",
- "shell <shell-command>"])
-
+ "shell <shell-command>",
+ "'shell' is an abbreviation"])
+ # "platform shell" has options. The "shell" alias for it does not.
+ self.expect("help shell", substrs=["Command Options:"], matching=False)
@no_debug_info_test
def test_list(self):
Index: lldb/source/Interpreter/Options.cpp
===================================================================
--- lldb/source/Interpreter/Options.cpp
+++ lldb/source/Interpreter/Options.cpp
@@ -403,7 +403,12 @@
} else
name = "";
- strm.PutCString("\nCommand Options Usage:\n");
+ const uint32_t num_options = NumCommandOptions();
+ if (num_options == 0)
+ return;
+
+ if (!only_print_args)
+ strm.PutCString("\nCommand Options Usage:\n");
strm.IndentMore(2);
@@ -413,10 +418,6 @@
// [options-for-level-1]
// etc.
- const uint32_t num_options = NumCommandOptions();
- if (num_options == 0)
- return;
-
uint32_t num_option_sets = GetRequiredOptions().size();
uint32_t i;
@@ -531,9 +532,9 @@
strm << " " << arguments_str.GetString();
}
- strm.Printf("\n\n");
-
if (!only_print_args) {
+ strm.Printf("\n\n");
+
// Now print out all the detailed information about the various options:
// long form, short form and help text:
// -short <argument> ( --long_name <argument> )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117004.398891.patch
Type: text/x-patch
Size: 2081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220111/6d6b48c6/attachment.bin>
More information about the lldb-commits
mailing list