From f2cb3a009456ec9115e41720e81ef031ed4eaf46 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 14 Jun 2017 21:37:38 -0400 Subject: Changed default value for USE_ARG_LIST global to True Now by default all @options commands get passed a list of argument strings instead of a single argument string. This is a much easier and more robust behavior to deal with. Additionally, command-line arguments are intelligently separated based on location of quotes to group things into a single argument. WARNING: This change breaks backward compatibility for older applicaitons based on cmd2. To change the behavior to the way it used to be, add the following code to the __init__() method of our class derived from cmd2.Cmd: cmd2.set_use_arg_list(False) This change really does make it easier for developers new to using cmd2 however. It is to the point where I create all custom commands with @options, even if I use an empty list for the options because the argument parsing is just much better this way. --- tests/test_transcript.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test_transcript.py') diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 5ac7d6fd..4a7d57a6 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -15,7 +15,7 @@ import six # Used for sm.input: raw_input() for Python 2 or input() for Python 3 import six.moves as sm -from cmd2 import Cmd, make_option, options, Cmd2TestCase +from cmd2 import Cmd, make_option, options, Cmd2TestCase, set_use_arg_list from conftest import run_cmd, StdOut, normalize @@ -28,6 +28,7 @@ class CmdLineApp(Cmd): # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x Cmd.__init__(self, *args, **kwargs) self.settable.append('maxrepeats Max number of `--repeat`s allowed') + set_use_arg_list(False) opts = [make_option('-p', '--piglatin', action="store_true", help="atinLay"), make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"), -- cgit v1.2.1