diff options
-rwxr-xr-x | cmd2.py | 12 | ||||
-rw-r--r-- | docs/freefeatures.rst | 10 |
2 files changed, 17 insertions, 5 deletions
@@ -1659,9 +1659,15 @@ Script should contain one command per line, just like command would be typed in return try: - # Add all commands in the script to the command queue - with open(expanded_path) as target: - self.cmdqueue.extend(target.read().splitlines()) + # Specify file encoding in Python 3, but Python 2 doesn't allow that argument to open() + if six.PY3: + # Add all commands in the script to the command queue + with open(expanded_path, encoding='utf-8') as target: + self.cmdqueue.extend(target.read().splitlines()) + else: + # Add all commands in the script to the command queue + with open(expanded_path) as target: + self.cmdqueue.extend(target.read().splitlines()) # Append in an "end of script (eos)" command to cleanup the self._script_dir list self.cmdqueue.append('eos') diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 7381ff8e..1c829f0a 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -13,15 +13,21 @@ Script files ============ Text files can serve as scripts for your ``cmd2``-based -application, with the ``load``, ``save``, and ``edit`` -commands. +application, with the ``load``, ``_relative_load``, ``save``, and ``edit`` commands. + +Both ASCII and UTF-8 encoded unicode text files are supported. + +Simply include one command per line, typed exactly as you would inside a ``cmd2`` application. .. automethod:: cmd2.Cmd.do_load +.. automethod:: cmd2.Cmd.do__relative_load + .. automethod:: cmd2.Cmd.do_save .. automethod:: cmd2.Cmd.do_edit + Comments ======== |