cloudmesh/cmd3 — pull request #1 by amimoto (2014-11-14 03:52:07+00:00)
Title: Add support for shlex 

Not sure if this is a helpful patch...

When using a command defined like the following:

"""Usage:
log
"""

It is not possible to issue a command such as:

log "an argument that contains spaces"

This will be broken into

['log', '"an', 'argument', 'that', 'contains', 'spaces"']

Which will break when it hits "log ".

The reason for this is by passing

docopt(doc, help=True, argv=args)

args ends up within docopt.TokenStream's __init__ where the code reads:

self += source.split() if hasattr(source, 'split') else source

source.split() splits on whitespace without respecting quotes.

By going through shlex's parse, it will break the arg string into fragments that (to me) seem a bit more regular and make it possible to supply arguments with spaces.

shlex is also apparently a part of the standard library so it probably won't cause a troublesome dependancy.