Changes to Python commands:
 - They now have an SBCommandReturnObject instead of an SBStream as third argument
 - The class CommandObjectPythonFunction has been merged into CommandObjectCommands.cpp
 - The command to manage them is now:
  command script with subcommands add, list, delete, clear
   command alias is returned to its previous functionality
 - Python commands are now part of an user dictionary, instead of being seen as aliases
 


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137785 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index ab50edf..d2e3a5b 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -264,7 +264,7 @@
     m_command_dict["source"]    = CommandObjectSP (new CommandObjectMultiwordSource (*this));
     m_command_dict["target"]    = CommandObjectSP (new CommandObjectMultiwordTarget (*this));
     m_command_dict["thread"]    = CommandObjectSP (new CommandObjectMultiwordThread (*this));
-    m_command_dict["type"]    = CommandObjectSP (new CommandObjectType (*this));
+    m_command_dict["type"]      = CommandObjectSP (new CommandObjectType (*this));
     m_command_dict["version"]   = CommandObjectSP (new CommandObjectVersion (*this));
 
     std::auto_ptr<CommandObjectRegexCommand>
@@ -457,6 +457,24 @@
     return false;
 }
 
+bool
+CommandInterpreter::AddUserCommand (const char *name, 
+                                    const lldb::CommandObjectSP &cmd_sp,
+                                    bool can_replace)
+{
+    if (name && name[0])
+    {
+        std::string name_sstr(name);
+        if (!can_replace)
+        {
+            if (m_user_dict.find (name_sstr) != m_user_dict.end())
+                return false;
+        }
+        m_user_dict[name_sstr] = cmd_sp;
+        return true;
+    }
+    return false;
+}
 
 CommandObjectSP
 CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliases)
@@ -682,21 +700,28 @@
 }
 
 void
-CommandInterpreter::GetHelp (CommandReturnObject &result)
+CommandInterpreter::GetHelp (CommandReturnObject &result,
+                             CommandTypes cmd_types)
 {
     CommandObject::CommandMap::const_iterator pos;
-    result.AppendMessage("The following is a list of built-in, permanent debugger commands:");
-    result.AppendMessage("");
     uint32_t max_len = FindLongestCommandWord (m_command_dict);
-
-    for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos)
+    
+    if ( (cmd_types & eCommandTypesBuiltin) == eCommandTypesBuiltin )
     {
-        OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(),
-                                 max_len);
-    }
-    result.AppendMessage("");
+    
+        result.AppendMessage("The following is a list of built-in, permanent debugger commands:");
+        result.AppendMessage("");
 
-    if (m_alias_dict.size() > 0)
+        for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos)
+        {
+            OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(),
+                                     max_len);
+        }
+        result.AppendMessage("");
+
+    }
+
+    if (m_alias_dict.size() > 0 && ( (cmd_types & eCommandTypesAliases) == eCommandTypesAliases ))
     {
         result.AppendMessage("The following is a list of your current command abbreviations "
                              "(see 'help command alias' for more info):");
@@ -718,13 +743,15 @@
         result.AppendMessage("");
     }
 
-    if (m_user_dict.size() > 0)
+    if (m_user_dict.size() > 0 && ( (cmd_types & eCommandTypesUserDef) == eCommandTypesUserDef ))
     {
         result.AppendMessage ("The following is a list of your current user-defined commands:");
         result.AppendMessage("");
+        max_len = FindLongestCommandWord (m_user_dict);
         for (pos = m_user_dict.begin(); pos != m_user_dict.end(); ++pos)
         {
-            result.AppendMessageWithFormat ("%s  --  %s\n", pos->first.c_str(), pos->second->GetHelp());
+            OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(),
+                                     max_len);
         }
         result.AppendMessage("");
     }