diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-15 11:09:24 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-15 11:09:24 +0100 |
commit | 068bebe06d28bed349e6f99f6703a2171c94fab8 (patch) | |
tree | fadbd373518562fd1719e0bcb540802458fcfed0 /alot/commands/__init__.py | |
parent | fcf49cf44ce6c9c3fe6a66a04f92bdc69835f022 (diff) |
use shlex
Diffstat (limited to 'alot/commands/__init__.py')
-rw-r--r-- | alot/commands/__init__.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py index 0adb75f3..80778113 100644 --- a/alot/commands/__init__.py +++ b/alot/commands/__init__.py @@ -1,6 +1,7 @@ import os import sys import glob +import shlex import logging import argparse import cStringIO @@ -74,12 +75,10 @@ def commandfactory(cmdline, mode='global'): if not cmdline: return None logging.debug('mode:%s got commandline "%s"' % (mode, cmdline)) - args = cmdline.split(' ', 1) + args = shlex.split(cmdline.encode('utf-8')) + logging.debug('ARGS: %s' % args) cmdname = args[0] - if args[1:]: - argstring = args[1] - else: - argstring = '' + args = args[1:] # unfold aliases if alot.settings.config.has_option('command-aliases', cmdname): @@ -97,9 +96,8 @@ def commandfactory(cmdline, mode='global'): logging.debug(msg) raise CommandParseError(msg) - logging.debug('PARSE: %s' % argstring) #logging.debug(parser) - parms = vars(parser.parse_args(argstring.split())) + parms = vars(parser.parse_args(args)) logging.debug('PARMS: %s' % parms) logging.debug(parms) @@ -125,12 +123,6 @@ def commandfactory(cmdline, mode='global'): # if params: # h = {'To': params} # return commandfactory(cmd, mode=mode, headers=h) -# elif cmd == 'attach': -# return commandfactory(cmd, mode=mode, path=params) -# elif cmd == 'help': -# return commandfactory(cmd, mode=mode, commandline=params) -# elif cmd == 'forward': -# return commandfactory(cmd, mode=mode, inline=(params == '--inline')) # elif cmd == 'prompt': # return commandfactory(cmd, mode=mode, startstring=params) # elif cmd == 'refine': |