summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-01-07 13:51:53 -0700
committerkotfu <kotfu@kotfu.net>2018-01-07 13:51:53 -0700
commitcc32105daa5c096a5c7fcd2b47729eebc871ebef (patch)
tree5a8ffda0edf7338a6b5f85e7ecf9ec75c3aa24cf /cmd2.py
parent4f54d10f4c8d5b5c03626a88f8198318a8080fc6 (diff)
downloadcmd2-git-cc32105daa5c096a5c7fcd2b47729eebc871ebef.tar.gz
Default posix and quote removal working.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/cmd2.py b/cmd2.py
index d62e8de6..15aa4576 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -31,6 +31,7 @@ import datetime
import glob
import io
import optparse
+import argparse
import os
import platform
import re
@@ -248,22 +249,19 @@ def with_argument_parser(argparser):
"""
def arg_decorator(func):
def cmd_wrapper(instance, arg):
- #print("before command")
+ print("before command")
# Use shlex to split the command line into a list of arguments based on shell rules
- opts = argparser.parse_args(shlex.split(arg, posix=POSIX_SHLEX))
- #import ipdb; ipdb.set_trace()
-
-
+ lexed_arglist = shlex.split(arg, posix=POSIX_SHLEX)
# If not using POSIX shlex, make sure to strip off outer quotes for convenience
if not POSIX_SHLEX and STRIP_QUOTES_FOR_NON_POSIX:
- newopts = opts
-# for key, val in vars(opts):
-# if isinstance(val, str):
-# newopts[key] = strip_quotes(val)
- opts = newopts
-### opts = argparser.parse_args(shlex.split(arg, posix=POSIX_SHLEX))
+ temp_arglist = []
+ for arg in lexed_arglist:
+ temp_arglist.append(strip_quotes(arg))
+ lexed_arglist = temp_arglist
+ opts = argparser.parse_args(lexed_arglist)
+
func(instance, arg, opts)
- #print("after command")
+ print("after command")
return cmd_wrapper
return arg_decorator