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> )
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> )
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits