summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorJared Crapo <jared@kotfu.net>2018-01-07 12:06:11 -0700
committerJared Crapo <jared@kotfu.net>2018-01-07 12:06:11 -0700
commitd63c878413006630834324d71bd22f012bc543a8 (patch)
tree70cd68c89067338921653038df21d3947bdfa46e /cmd2.py
parent67e669e3345fb637e4f4779691a7a8ec4b1763f6 (diff)
downloadcmd2-git-d63c878413006630834324d71bd22f012bc543a8.tar.gz
New test cases for argparse
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index 9b0bc66a..3f19c816 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -247,10 +247,22 @@ 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()
+
+
+ # 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))
func(instance, arg, opts)
- print("after command")
+ #print("after command")
return cmd_wrapper
return arg_decorator