diff options
-rwxr-xr-x | README.md | 2 | ||||
-rwxr-xr-x | cmd2.py | 13 | ||||
-rw-r--r-- | docs/index.rst | 3 |
3 files changed, 11 insertions, 7 deletions
@@ -137,7 +137,7 @@ Tutorials A few tutorials on using cmd2 exist: -* Florida PyCon 2017 talk: [slides](https://docs.google.com/presentation/d/1LRmpfBt3V-pYQfgQHdczf16F3hcXmhK83tl77R6IJtE) +* Florida PyCon 2017 talk: [slides](https://docs.google.com/presentation/d/1LRmpfBt3V-pYQfgQHdczf16F3hcXmhK83tl77R6IJtE), [video](https://www.youtube.com/watch?v=6m0RdpITaeY) * PyCon 2010 talk by Catherine Devlin, the original author: [video](http://pyvideo.org/pycon-us-2010/pycon-2010--easy-command-line-applications-with-c.html) * A nice brief step-by-step tutorial: [blog](https://kushaldas.in/posts/developing-command-line-interpreters-using-python-cmd2.html) @@ -577,7 +577,9 @@ def replace_with_file_contents(fname): :return: str - contents of file "fname" """ try: - with open(os.path.expanduser(fname[0])) as source_file: + # Any outer quotes are not part of the filename + unquoted_file = strip_quotes(fname[0]) + with open(os.path.expanduser(unquoted_file)) as source_file: result = source_file.read() except IOError: result = '< %s' % fname[0] # wasn't a file after all @@ -3467,8 +3469,8 @@ class ParserManager: pyparsing.Optional(pipe + pyparsing.SkipTo(output_destination_parser ^ string_end, ignore=do_not_parse)('pipeTo')) + \ pyparsing.Optional(output_destination_parser + - pyparsing.SkipTo(string_end, - ignore=do_not_parse).setParseAction(lambda x: x[0].strip())('outputTo')) + pyparsing.SkipTo(string_end, ignore=do_not_parse). + setParseAction(lambda x: strip_quotes(x[0].strip()))('outputTo')) multilineCommand.setParseAction(lambda x: x[0]) oneline_command.setParseAction(lambda x: x[0]) @@ -3515,7 +3517,10 @@ class ParserManager: input_mark = pyparsing.Literal('<') input_mark.setParseAction(lambda x: '') - file_name = pyparsing.Word(legalChars + '/\\') + + # Also allow spaces, slashes, and quotes + file_name = pyparsing.Word(legalChars + ' /\\"\'') + input_from = file_name('inputFrom') input_from.setParseAction(replace_with_file_contents) # a not-entirely-satisfactory way of distinguishing < as in "import from" from < diff --git a/docs/index.rst b/docs/index.rst index b034dafd..70b1b69a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -47,8 +47,7 @@ Resources * cmd_ * `cmd2 project page`_ * `project bug tracker`_ -* Florida PyCon 2017: `slides <https://docs.google.com/presentation/d/1LRmpfBt3V-pYQfgQHdczf16F3hcXmhK83tl77R6IJtE>`_ -* PyOhio 2011: `video <https://archive.org/details/pyvideo_541___pyohio-2011-interactive-command-line-interpreters-with-cmd-and-cmd2>`_ +* Florida PyCon 2017: `slides <https://docs.google.com/presentation/d/1LRmpfBt3V-pYQfgQHdczf16F3hcXmhK83tl77R6IJtE>`_, `video <https://www.youtube.com/watch?v=6m0RdpITaeY>`_ These docs will refer to ``App`` as your ``cmd2.Cmd`` subclass, and ``app`` as an instance of ``App``. Of |