1. Tuomas Räsänen
  2. subssh

Commits

Tuomas Räsänen  committed deb905a

subssh/tools.py: to_cmd_args(): list of strings to (cmd, args) pair.

  • Participants
  • Parent commits 36d5c6b
  • Branches default

Comments (0)

Files changed (2)

File subssh/shell.py

View file
 <http://www.gnu.org/licenses/>.
 """
 
-
 import readline
 
-
 import apprunner
 import tools
 import config
 import active
 
-
-
-
 def complete(text, state):
     for cmd, app in active.user_apps():
         if cmd.startswith(text):
             else:
                 state -= 1
 
-
 readline.set_completer_delims(' `~!@#$%^&*()=+[{]}\|;:\'",<>/?')
 readline.parse_and_bind("tab: complete")
 readline.set_completer(complete)
 
 def prompt(user):
-    
-
-    
     exit_status = 0
     cmd = ""
     args = []
             print "exit",
             return 0
         
-        cmd, args = tools.to_cmd_args(input)
+        cmd, args = tools.to_cmd_args(input.split())
         
         if not cmd:
             continue
         exit_status = apprunner.run(user)
         
     return exit_status
-
-    

File subssh/tools.py

View file
         return False
     raise ValueError("%s is not a valid boolean value" % value)
 
-def to_cmd_args(input):
-    if isinstance(input, str):
-        parts = input.split()
-    else:
-        parts = input
+def to_cmd_args(parts):
+    """Return (cmd, args) pair from a list of strings.
+
+    The first element of `parts` is the command string and the rest are
+    string arguments. If `parts` is empty, ("", []) is returned.
+    """
     
     try:
         cmd = parts[0]
     except IndexError:
-        cmd = ""
+        return "", []
     
-    try:
-        args = parts[1:]
-    except IndexError:
-        args = []        
-        
-    return cmd, args
-    
-    
-
-    
-
+    return cmd, parts[1:]
 
 def writeln(msg="", out=sys.stdout, log=None, indent=None):
     if log and msg: