From: Patrick Donnelly Date: Mon, 21 Jan 2019 22:45:07 +0000 (-0800) Subject: ceph: omit hidden commands from suggestions X-Git-Tag: v14.1.0~111^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=19fbdb3ffde5bcb73792b1d822fe3f8d0407d490;p=ceph-ci.git ceph: omit hidden commands from suggestions Fixes: http://tracker.ceph.com/issues/37955 Signed-off-by: Patrick Donnelly --- diff --git a/src/ceph.in b/src/ceph.in index eff2a59a945..85e66289dd8 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -38,13 +38,6 @@ CEPH_RELEASE = "@CEPH_RELEASE@" CEPH_RELEASE_NAME = "@CEPH_RELEASE_NAME@" CEPH_RELEASE_TYPE = "@CEPH_RELEASE_TYPE@" -# Flags from src/mon/Monitor.h -FLAG_NOFORWARD = (1 << 0) -FLAG_OBSOLETE = (1 << 1) -FLAG_DEPRECATED = (1 << 2) -FLAG_POLL = (1 << 4) -FLAG_HIDDEN = (1 << 5) - # priorities from src/common/perf_counters.h PRIO_CRITICAL = 10 PRIO_INTERESTING = 8 @@ -478,7 +471,7 @@ def format_help(cmddict, partial=None): if not cmd['help']: continue flags = cmd.get('flags', 0) - if flags & (FLAG_OBSOLETE | FLAG_DEPRECATED | FLAG_HIDDEN): + if flags & (argparse.FLAG_OBSOLETE | argparse.FLAG_DEPRECATED | argparse.FLAG_HIDDEN): continue concise = concise_sig(cmd['sig']) if partial and not concise.startswith(partial): diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index f0da4ed8fad..4f6e1d87f50 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -23,10 +23,13 @@ import sys import threading import uuid - # Flags are from MonCommand.h -FLAG_MGR = 8 # command is intended for mgr -FLAG_POLL = 16 # command is intended to be ran continuously by the client +FLAG_NOFORWARD = (1 << 0) +FLAG_OBSOLETE = (1 << 1) +FLAG_DEPRECATED = (1 << 2) +FLAG_MGR = (1<<3) +FLAG_POLL = (1 << 4) +FLAG_HIDDEN = (1 << 5) KWARG_EQUALS = "--([^=]+)=(.+)" KWARG_SPACE = "--([^=]+)" @@ -1129,6 +1132,9 @@ def validate_command(sigdict, args, verbose=False): best_match_cnt = 0 bestcmds = [] for cmd in sigdict.values(): + flags = cmd.get('flags', 0) + if flags & FLAG_OBSOLETE: + continue sig = cmd['sig'] matched = matchnum(args, sig, partial=True) if (matched >= math.floor(best_match_cnt) and @@ -1193,7 +1199,8 @@ def validate_command(sigdict, args, verbose=False): print("Invalid command:", ex, file=sys.stderr) print(concise_sig(sig), ': ', cmd['help'], file=sys.stderr) else: - bestcmds = bestcmds[:10] + bestcmds = [c for c in bestcmds if not c.get('flags', 0) & (FLAG_DEPRECATED | FLAG_HIDDEN)] + bestcmds = bestcmds[:10] # top 10 print('no valid command found; {0} closest matches:'.format(len(bestcmds)), file=sys.stderr) for cmd in bestcmds: print(concise_sig(cmd['sig']), file=sys.stderr)