Index: src/test/org/codehaus/groovy/tools/shell/commands/RegisterCommandTest.groovy
===================================================================
--- src/test/org/codehaus/groovy/tools/shell/commands/RegisterCommandTest.groovy	(revision 0)
+++ src/test/org/codehaus/groovy/tools/shell/commands/RegisterCommandTest.groovy	(revision 0)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2003-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.codehaus.groovy.tools.shell.commands
+
+import org.codehaus.groovy.tools.shell.CommandException
+import org.codehaus.groovy.tools.shell.CommandSupport
+import org.codehaus.groovy.tools.shell.Shell
+
+/**
+ * Tests for the     {@link RegisterCommand}     class.
+ *
+ * @version $Id: AliasCommandTest.groovy 8447 2007-10-07 10:17:11Z user57 $
+ * @author <a href="mailto:chris@wensel.net">Chris K Wensel</a>
+ */
+class RegisterCommandTest
+extends CommandTestSupport {
+
+    void testRegister() {
+        shell << 'register org.codehaus.groovy.tools.shell.commands.EchoCommand'
+    }
+
+    void testRegisterDupes() {
+        shell << 'register org.codehaus.groovy.tools.shell.commands.EchoCommand'
+        shell << 'register org.codehaus.groovy.tools.shell.commands.EchoCommand echo2 \\e2'
+    }
+
+    void testRegisterDupesFail() {
+        try {
+            shell << 'register org.codehaus.groovy.tools.shell.commands.EchoCommand'
+            shell << 'register org.codehaus.groovy.tools.shell.commands.EchoCommand'
+            fail()
+        }
+        catch (CommandException expected) {}
+    }
+
+    void testRegisterFail() {
+        try {
+            shell << 'register'
+            fail()
+        }
+        catch (CommandException expected) {}
+    }
+}
+
+class EchoCommand
+extends CommandSupport {
+
+    EchoCommand(final Shell shell, final String name, final String alias) {
+        super(shell, name, alias)
+    }
+
+    EchoCommand(final Shell shell) {
+        super(shell, 'echo', '\\ec')
+    }
+
+    Object execute(final List args) {
+        io.out.println(args.join(' ')) //  TODO: i18n
+    }
+}
+
+
Index: src/test/org/codehaus/groovy/tools/shell/commands/EchoCommand.properties
===================================================================
--- src/test/org/codehaus/groovy/tools/shell/commands/EchoCommand.properties	(revision 12055)
+++ src/test/org/codehaus/groovy/tools/shell/commands/EchoCommand.properties	(working copy)
@@ -18,7 +18,6 @@
 # $Id$
 #
 
-command.description=Create an alias
-command.usage=
-command.help=Create an alias.
-
+command.description=Echo the args
+command.usage=<args>
+command.help=Echo the args.
\ No newline at end of file
Index: src/main/org/codehaus/groovy/tools/shell/commands.xml
===================================================================
--- src/main/org/codehaus/groovy/tools/shell/commands.xml	(revision 12100)
+++ src/main/org/codehaus/groovy/tools/shell/commands.xml	(working copy)
@@ -19,35 +19,37 @@
 
 <commands>
     <command>org.codehaus.groovy.tools.shell.commands.HelpCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.ExitCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.ImportCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.DisplayCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.ClearCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.ShowCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.InspectCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.PurgeCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.EditCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.LoadCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.SaveCommand</command>
 
     <command>org.codehaus.groovy.tools.shell.commands.RecordCommand</command>
 
     <command>org.codehaus.groovy.tools.shell.commands.HistoryCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.AliasCommand</command>
-    
+
     <command>org.codehaus.groovy.tools.shell.commands.SetCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ShadowCommand</command>
     
-    <command>org.codehaus.groovy.tools.shell.commands.ShadowCommand</command>
+    <command>org.codehaus.groovy.tools.shell.commands.RegisterCommand</command>
 </commands>
 
Index: src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.groovy
===================================================================
--- src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.groovy	(revision 0)
+++ src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.groovy	(revision 0)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2003-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.codehaus.groovy.tools.shell.commands
+
+import org.codehaus.groovy.tools.shell.CommandSupport
+import org.codehaus.groovy.tools.shell.Shell
+import org.codehaus.groovy.tools.shell.Command
+
+/**
+ * The 'register' command.
+ *
+ * @version $Id: PurgeCommand.groovy 8449 2007-10-07 10:18:00Z user57 $
+ * @author <a href="mailto:chris@wensel.net">Chris K Wensel</a>
+ */
+class RegisterCommand
+extends CommandSupport {
+
+    RegisterCommand(final Shell shell) {
+        super(shell, "register", "\\rc")
+    }
+
+    public Object execute(List args) {
+        assert args != null
+
+        if (args.size() < 1) {
+            fail("Command 'register' requires at least 1 arguments") // TODO: i18n
+        }
+
+        String classname = args.get(0)
+
+        Class type = getClassLoader().loadClass(classname)
+
+        Command command = null;
+
+        if (args.size() == 1)                   // use default name
+            command = type.newInstance(shell)
+        else if (args.size() == 2)              // pass name to ctor
+            command = type.newInstance(shell, args.get(1), null)
+        else if (args.size() == 3)              // pass name, alias to ctor
+            command = type.newInstance(shell, args.get(1), args.get(2))
+
+        def oldcommand = registry[command.name] // let's prevent collisions
+
+        if (oldcommand) {
+            fail("Can not rebind command: ${command.name}") // TODO: i18n
+        }
+
+        if (log.debugEnabled) {
+            log.debug("Created command '${command.name}': $command")
+        }
+
+        command = shell << command
+
+        if (shell.runner) {
+            shell.runner.completor << command
+        }
+
+    }
+
+}
\ No newline at end of file
Index: src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.properties
===================================================================
--- src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.properties	(revision 12055)
+++ src/main/org/codehaus/groovy/tools/shell/commands/RegisterCommand.properties	(working copy)
@@ -18,7 +18,7 @@
 # $Id$
 #
 
-command.description=Create an alias
-command.usage=
-command.help=Create an alias.
+command.description=Registers a new command with the shell
+command.usage=<classname> [<name>] [alias]
+command.help=Registers the given @|BOLD classname| as a new command.
 
