Author: jingham Date: Thu Dec 20 17:45:28 2018 New Revision: 349874 URL: http://llvm.org/viewvc/llvm-project?rev=349874&view=rev Log: "help finish" tells you it is an alias. "help fin" doesn't.
They both run the same command, and people get used to typing the shortest string they can, so we should support alias info on shortened strings as well. <rdar://problem/46859207> Modified: lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py lldb/trunk/source/Commands/CommandObjectHelp.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py?rev=349874&r1=349873&r2=349874&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py Thu Dec 20 17:45:28 2018 @@ -231,6 +231,17 @@ class HelpCommandTestCase(TestBase): self.expect("help averyfriendlyalias", matching=True, substrs=['I am a very friendly alias']) @no_debug_info_test + def test_alias_prints_origin(self): + """Test that 'help <unique_match_to_alias>' prints the alias origin.""" + def cleanup(): + self.runCmd('command unalias alongaliasname', check=False) + + self.addTearDownHook(cleanup) + self.runCmd('command alias alongaliasname help') + self.expect("help alongaliasna", matching=True, + substrs=["'alongaliasna' is an abbreviation for 'help'"]) + + @no_debug_info_test def test_help_format_output(self): """Test that help output reaches TerminalWidth.""" self.runCmd( Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=349874&r1=349873&r2=349874&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Thu Dec 20 17:45:28 2018 @@ -167,10 +167,13 @@ bool CommandObjectHelp::DoExecute(Args & } sub_cmd_obj->GenerateHelpText(result); - - if (m_interpreter.AliasExists(command_name)) { + std::string alias_full_name; + // Don't use AliasExists here, that only checks exact name matches. If + // the user typed a shorter unique alias name, we should still tell them + // it was an alias. + if (m_interpreter.GetAliasFullName(command_name, alias_full_name)) { StreamString sstr; - m_interpreter.GetAlias(command_name)->GetAliasExpansion(sstr); + m_interpreter.GetAlias(alias_full_name)->GetAliasExpansion(sstr); result.GetOutputStream().Printf("\n'%s' is an abbreviation for %s\n", command[0].c_str(), sstr.GetData()); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits