* file_path - path to a file to open in editor
-load
-----
+run_script
+----------
Runs commands in script file that is encoded as either ASCII or UTF-8 text.
+Each command in the script should be separated by a newline.
Usage:
- load <file_path>
+ run_script <file_path>
+
* file_path - a file path pointing to a script
-* Script should contain one command per line, just like command would betyped in console.
+.. note:: This command is available as ``load`` for cmd2 versions 0.9.13
+ or less.
shell
-----
import os
import os.path
import sys
-from cmd2 import Cmd
import cephfs as libcephfs
import shutil
import traceback
import shlex
import stat
+from cmd2 import Cmd
+from cmd2 import __version__ as cmd2_version
+from distutils.version import LooseVersion
+
if sys.version_info.major < 3:
raise RuntimeError("cephfs-shell is only compatible with python3")
if args.config:
config_file = args.config
if args.batch:
- args.commands = ['load ' + args.batch, ',quit']
+ if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
+ args.commands = ['load ' + args.batch, ',quit']
+ else:
+ args.commands = ['run_script ' + args.batch, ',quit']
if args.test:
args.commands.extend(['-t,'] + [arg + ',' for arg in args.test])
sys.argv.clear()