From: Sage Weil Date: Sat, 8 Feb 2020 14:49:50 +0000 (-0600) Subject: ceph.in: fix -h/help behavior for tell commands X-Git-Tag: v15.1.1~477^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=013a5cc3f87a2dcb8d81d19dcf1a582b5d91bfee;p=ceph.git ceph.in: fix -h/help behavior for tell commands - add "Tell $type commands" heading - 'ceph tell mon.a -h' now works - 'ceph tell mon.a prefix -h' also works Signed-off-by: Sage Weil --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 9a3a98b8dca1..e97f9a13d43d 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -2673,7 +2673,9 @@ function test_mon_pool_application() function test_mon_tell_help_command() { - ceph tell mon.a help + ceph tell mon.a help | grep sync_force + ceph tell mon.a -h | grep sync_force + ceph tell mon.a config -h | grep 'config diff get' # wrong target expect_false ceph tell mon.zzz help diff --git a/src/ceph.in b/src/ceph.in index d359e257cd6c..ced2c1effcf0 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -1032,21 +1032,33 @@ def main(): return 1 if parsed_args.help: - hdr('Monitor commands:') + target = None + if len(childargs) >= 2 and childargs[0] == 'tell': + target = childargs[1].split('.') + if not validate_target(target): + print('target {0} doesn\'t exist; please pass correct target to tell command (e.g., mon.a, osd.1, mds.a, mgr)'.format(childargs[1]), file=sys.stderr) + return 1 + childargs = childargs[2:] + hdr('Tell %s commands:' % target[0]) + else: + hdr('Monitor commands:') + target = ('mon', '') if verbose: print('[Contacting monitor, timeout after %d seconds]' % timeout) - return do_extended_help(parser, childargs, ('mon', ''), ' '.join(childargs)) + return do_extended_help(parser, childargs, target, ' '.join(childargs)) # implement "tell service.id help" if len(childargs) >= 3 and childargs[0] == 'tell' and childargs[2] == 'help': target = childargs[1].split('.') if validate_target(target): + hdr('Tell %s commands' % target[0]) return do_extended_help(parser, childargs, target, None) else: print('target {0} doesn\'t exists, please pass correct target to tell command, such as mon.a/' 'osd.1/mds.a/mgr'.format(childargs[1]), file=sys.stderr) return 1 + # implement -w/--watch_* # This is ugly, but Namespace() isn't quite rich enough. level = ''