diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-14 21:37:38 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-14 21:37:38 -0400 |
commit | f2cb3a009456ec9115e41720e81ef031ed4eaf46 (patch) | |
tree | f72647fe6918977fe038725e40e3b6e172874943 /cmd2.py | |
parent | 056ea31581af194971816f4150e4f8c2aa7b000c (diff) | |
download | cmd2-git-f2cb3a009456ec9115e41720e81ef031ed4eaf46.tar.gz |
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.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -97,8 +97,8 @@ pyparsing.ParserElement.setDefaultWhitespaceChars(' \t') # The next 3 variables and associated setter functions effect how arguments are parsed for commands using @options. -# The defaults are "sane" and maximize backward compatibility with cmd and previous versions of cmd2. -# But depending on your particular application, you may wish to tweak them so you get the desired parsing behavior. +# The defaults are "sane" and maximize ease of use for new applications based on cmd2. +# To maximize backwards compatibility, we recommend setting USE_ARG_LIST to "False" # Use POSIX or Non-POSIX (Windows) rules for splitting a command-line string into a list of arguments via shlex.split() POSIX_SHLEX = False @@ -107,7 +107,7 @@ POSIX_SHLEX = False STRIP_QUOTES_FOR_NON_POSIX = True # For option commands, pass a list of argument strings instead of a single argument string to the do_* methods -USE_ARG_LIST = False +USE_ARG_LIST = True def set_posix_shlex(val): |