New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ceph: bash auto complete for CLI based on mon command descriptions #7693
Conversation
if not matches: | ||
continue | ||
|
||
if j < len(sig) and len(args)>0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aclamk could you run this script through pep8? i see some of your change does not follow it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay. fwiw, you can install it using pip install pep8
.
@aclamk and you might need to revise your commit message with more concise title and a |
7b7a44e
to
89746dc
Compare
@aclamk do you mind rebasing this on master to resolve the conflict? thanks! |
89746dc
to
9f7a8a7
Compare
2016-03-22T07:24:07.627 INFO:teuthology.orchestra.run.smithi024.stderr: File "/bin/ceph", line 523 |
if match_count == 1 and len(comps) == 0: | ||
# only one command matched and no hints yet => add help | ||
comps = comps + [' ', '#'+match_cmd['help']] | ||
print '\n'.join(sorted(set(comps))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aclamk might need to fix this.
9f7a8a7
to
6733bde
Compare
else: | ||
# successfully matched all - except last one - arguments | ||
if j < len(sig) and len(args) > 0: | ||
comps = comps + sig[j].complete(args[-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also put
comps += sig[j].complete(args[-1])
@aclamk could you please add the bind to bash in "src/bash_completion/ceph", so we can include this feature in jewel? |
# This is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License version 2.1, as published by the Free Software | ||
# Foundation. See file COPYING. | ||
# Foundation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing space.
@aclamk could you
? or you could just squash it into the previous one. |
@@ -512,9 +512,9 @@ def complete(sigdict, args, target): | |||
else: | |||
# successfully matched all - except last one - arguments | |||
if j < len(sig) and len(args) > 0: | |||
comps = comps + sig[j].complete(args[-1]) | |||
comps += sig[j].complete(args[-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better off moving this change to the previous commit.
#skip this word if it is option | ||
if [[ " ${options_noarg} " =~ " ${COMP_WORDS[i]} " ]] ; then continue; fi | ||
#skip this word and next if it is option with arg | ||
if [[ " ${options_arg} " =~ " ${COMP_WORDS[i]} " ]] ; then ((i++)); continue; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could remove the extra spaces? or break the if
block into multiple lines.
tested, works great! lgtm apart from some formatting nits. |
Now logic moved from bash to python. Not bind to bash yet. Use as 'ceph --comp osd ls'. Able to fulfill commands and print command line help. Signed-off-by: Adam Kupczyk <a.kupczyk@mirantis.com>
bc8c3bf
to
f9591f5
Compare
@tchaikov: added signed-off, reformatted bash code, removed spaces. Please take a look and comment. |
@aclamk could you remove the heading spaces in the commit message of f9591f5
and add a prefix of "bash_completion: " to the first line of it. and the commit message is not accurate, imho. we have a bash-completion for ceph CLI, but your change improves it by using the updated "ceph --completion". |
Signed-off-by: Adam Kupczyk <a.kupczyk@mirantis.com>
f9591f5
to
81a55d3
Compare
@tchaikov: Its a pleasure to polish out work with you. |
lgtm |
my pleasure also! =) |
@@ -1,73 +1,50 @@ | |||
# | |||
# Ceph - scalable distributed file system | |||
# | |||
# Copyright (C) 2011 Wido den Hollander <wido@widodh.nl> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you delete that copyright ?
Since the merge of pr ceph#7693, 'ceph <command>' to get the help is invalid. As a result, 'test/cephtool-test-mon.sh' test was broken This patch simply change the 'ceph <command>' by a 'ceph --help <command>' Since this change the test is passing again. Signed-off-by: Erwan Velu <erwan@redhat.com>
Since the merge of pr ceph#7693, 'ceph command' to get the help is invalid. As a result, 'test/cephtool-test-mon.sh' test was broken This patch simply change the 'ceph command' by a 'ceph --help command' Since this change the test is passing again. Signed-off-by: Erwan Velu <erwan@redhat.com>
|
@aclamk ok make sense. |
Since the merge of pr ceph#7693, 'ceph command' to get the help is invalid. As a result, 'test/cephtool-test-mon.sh' test was broken This patch simply change the 'ceph command' by a 'ceph --help command' Since this change the test is passing again. Signed-off-by: Erwan Velu <erwan@redhat.com>
This is not bind to bash yet. Use as 'ceph --comp osd ls'.
Able to fulfill commands as well as print command line help, when matching is complete.
This is required step before adding hinting of string values, eg. pool names.
Signed-off-by: Adam Kupczyk(a.kupczyk@mirantis.com)