]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephfs-shell: make compatible with cmd2 versions after 0.9.13
authorRishabh Dave <ridave@redhat.com>
Thu, 26 Sep 2019 07:59:55 +0000 (13:29 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 3 Oct 2019 12:40:59 +0000 (18:10 +0530)
"load" command from cmd2 has been renamed to "run_script". Update the
documentation for the same.

Fixes: https://tracker.ceph.com/issues/42057
Signed-off-by: Rishabh Dave <ridave@redhat.com>
doc/cephfs/cephfs-shell.rst
src/tools/cephfs/cephfs-shell

index 3825598fa49a3d187e974e9c1f4f9b5d70e11364..de62abc13c79ab99b71f84fe9799f700178bec49 100644 (file)
@@ -328,18 +328,21 @@ Usage:
 
 * 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
 -----
index 7dd1fe17ad98f1d40a4f4dc3b493577b08541eae..60bd7f5e1e4a6713f1a202b84cfc336b7268ba47 100755 (executable)
@@ -5,7 +5,6 @@ import argparse
 import os
 import os.path
 import sys
-from cmd2 import Cmd
 import cephfs as libcephfs
 import shutil
 import traceback
@@ -16,6 +15,10 @@ import re
 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")
 
@@ -1332,7 +1335,10 @@ if __name__ == '__main__':
     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()