{"action":"created","comment":{"url":"https://api.github.com/repos/ceph/ceph/pulls/comments/57739266","id":57739266,"diff_hunk":"@@ -491,46 +492,38 @@ def complete(sigdict, args, target):\n         args = args[2:]\n     # look for best match, accumulate possibles in bestcmds\n     # (so we can maybe give a more-useful error message)\n-    best_match_cnt = 0\n-    bestcmds = []\n+\n+    match_count = 0\n+    comps = []\n     for cmdtag, cmd in sigdict.iteritems():\n         sig = cmd['sig']\n-        matched = matchnum(args, sig, partial=True)\n-        if (matched > best_match_cnt):\n-            if complete_verbose:\n-                print(\"better match: {0} > {1}: {2}:{3} \".format(matched,\n-                        best_match_cnt, cmdtag, concise_sig(sig)),  file=sys.stderr)\n-            best_match_cnt = matched\n-            bestcmds = [{cmdtag:cmd}]\n-        elif matched == best_match_cnt:\n-            if complete_verbose:\n-                print(\"equal match: {0} > {1}: {2}:{3} \".format(matched,\n-                        best_match_cnt, cmdtag, concise_sig(sig)), file=sys.stderr)\n-            bestcmds.append({cmdtag:cmd})\n-\n-    # look through all matching sigs\n-    comps = []\n-    for cmddict in bestcmds:\n-        for cmd in cmddict.itervalues():\n-            sig = cmd['sig']\n-            # either:\n-            #   we match everything fully, so we want the next desc, or\n-            #   we match more partially, so we want the partial match\n-            fullindex = matchnum(args, sig, partial=False) - 1\n-            partindex = matchnum(args, sig, partial=True) - 1\n-            if complete_verbose:\n-                print('{}: f {} p {} len {}'.format(sig, fullindex, partindex, len(sig)), file=sys.stderr)\n-            if fullindex == partindex and fullindex + 1 < len(sig):\n-                d = sig[fullindex + 1]\n-            else:\n-                d = sig[partindex]\n-            comps.append(str(d))\n-    if complete_verbose:\n-        print('\\n'.join(comps), file=sys.stderr)\n-    print('\\n'.join(comps))\n+        j = 0\n+        # iterate over all arguments, except last one\n+        for arg in args[0:-1]:\n+            if j > len(sig)-1:\n+                # an out of argument definitions\n+                break\n+            found_match = arg in sig[j].complete(arg)\n+            if not found_match and sig[j].req:\n+                # no elements that match\n+                break\n+            if not sig[j].N:\n+                j += 1\n+        else:\n+            # successfully matched all - except last one - arguments\n+            if j < len(sig) and len(args) > 0:\n+                comps = comps + sig[j].complete(args[-1])\n+\n+            match_count = match_count + 1\n+            match_cmd = cmd\n \n+    if match_count == 1 and len(comps) == 0:\n+        # only one command matched and no hints yet => add help\n+        comps = comps + [' ', '#'+match_cmd['help']]","path":"src/ceph.in","position":74,"original_position":74,"commit_id":"6733bde8b7acd1dc4888cb2d613a409f763eac38","original_commit_id":"6733bde8b7acd1dc4888cb2d613a409f763eac38","user":{"login":"tchaikov","id":59071,"avatar_url":"https://avatars.githubusercontent.com/u/59071?v=3","gravatar_id":"","url":"https://api.github.com/users/tchaikov","html_url":"https://github.com/tchaikov","followers_url":"https://api.github.com/users/tchaikov/followers","following_url":"https://api.github.com/users/tchaikov/following{/other_user}","gists_url":"https://api.github.com/users/tchaikov/gists{/gist_id}","starred_url":"https://api.github.com/users/tchaikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchaikov/subscriptions","organizations_url":"https://api.github.com/users/tchaikov/orgs","repos_url":"https://api.github.com/users/tchaikov/repos","events_url":"https://api.github.com/users/tchaikov/events{/privacy}","received_events_url":"https://api.github.com/users/tchaikov/received_events","type":"User","site_admin":false},"body":"could you add space before and after `+`? guess pep8 will catch it..","created_at":"2016-03-29T15:05:55Z","updated_at":"2016-03-29T15:05:55Z","html_url":"https://github.com/ceph/ceph/pull/7693#discussion_r57739266","pull_request_url":"https://api.github.com/repos/ceph/ceph/pulls/7693","_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments/57739266"},"html":{"href":"https://github.com/ceph/ceph/pull/7693#discussion_r57739266"},"pull_request":{"href":"https://api.github.com/repos/ceph/ceph/pulls/7693"}}},"pull_request":{"url":"https://api.github.com/repos/ceph/ceph/pulls/7693","id":59773807,"html_url":"https://github.com/ceph/ceph/pull/7693","diff_url":"https://github.com/ceph/ceph/pull/7693.diff","patch_url":"https://github.com/ceph/ceph/pull/7693.patch","issue_url":"https://api.github.com/repos/ceph/ceph/issues/7693","number":7693,"state":"open","locked":false,"title":"Auto complete feature for CLI. Now logic moved from bash to python.","user":{"login":"aclamk","id":13020832,"avatar_url":"https://avatars.githubusercontent.com/u/13020832?v=3","gravatar_id":"","url":"https://api.github.com/users/aclamk","html_url":"https://github.com/aclamk","followers_url":"https://api.github.com/users/aclamk/followers","following_url":"https://api.github.com/users/aclamk/following{/other_user}","gists_url":"https://api.github.com/users/aclamk/gists{/gist_id}","starred_url":"https://api.github.com/users/aclamk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclamk/subscriptions","organizations_url":"https://api.github.com/users/aclamk/orgs","repos_url":"https://api.github.com/users/aclamk/repos","events_url":"https://api.github.com/users/aclamk/events{/privacy}","received_events_url":"https://api.github.com/users/aclamk/received_events","type":"User","site_admin":false},"body":"This is not bind to bash yet. Use as 'ceph --comp osd ls'.\r\nAble to fulfill commands as well as print command line help, when matching is complete.\r\nThis is required step before adding hinting of string values, eg. pool names.\r\nSigned-off-by: Adam Kupczyk(a.kupczyk@mirantis.com)","created_at":"2016-02-18T09:51:53Z","updated_at":"2016-03-29T15:05:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99f9bc41158189193bd8fa80a9a963e210bfd3da","assignee":{"login":"tchaikov","id":59071,"avatar_url":"https://avatars.githubusercontent.com/u/59071?v=3","gravatar_id":"","url":"https://api.github.com/users/tchaikov","html_url":"https://github.com/tchaikov","followers_url":"https://api.github.com/users/tchaikov/followers","following_url":"https://api.github.com/users/tchaikov/following{/other_user}","gists_url":"https://api.github.com/users/tchaikov/gists{/gist_id}","starred_url":"https://api.github.com/users/tchaikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchaikov/subscriptions","organizations_url":"https://api.github.com/users/tchaikov/orgs","repos_url":"https://api.github.com/users/tchaikov/repos","events_url":"https://api.github.com/users/tchaikov/events{/privacy}","received_events_url":"https://api.github.com/users/tchaikov/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/ceph/ceph/milestones/8","html_url":"https://github.com/ceph/ceph/milestones/jewel","labels_url":"https://api.github.com/repos/ceph/ceph/milestones/8/labels","id":1403256,"number":8,"title":"jewel","description":"","creator":{"login":"dillaman","id":4739042,"avatar_url":"https://avatars.githubusercontent.com/u/4739042?v=3","gravatar_id":"","url":"https://api.github.com/users/dillaman","html_url":"https://github.com/dillaman","followers_url":"https://api.github.com/users/dillaman/followers","following_url":"https://api.github.com/users/dillaman/following{/other_user}","gists_url":"https://api.github.com/users/dillaman/gists{/gist_id}","starred_url":"https://api.github.com/users/dillaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dillaman/subscriptions","organizations_url":"https://api.github.com/users/dillaman/orgs","repos_url":"https://api.github.com/users/dillaman/repos","events_url":"https://api.github.com/users/dillaman/events{/privacy}","received_events_url":"https://api.github.com/users/dillaman/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":271,"state":"open","created_at":"2015-11-09T22:29:48Z","updated_at":"2016-03-29T15:02:41Z","due_on":"2016-03-20T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/ceph/ceph/pulls/7693/commits","review_comments_url":"https://api.github.com/repos/ceph/ceph/pulls/7693/comments","review_comment_url":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ceph/ceph/issues/7693/comments","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/6733bde8b7acd1dc4888cb2d613a409f763eac38","head":{"label":"aclamk:auto_complete_python","ref":"auto_complete_python","sha":"6733bde8b7acd1dc4888cb2d613a409f763eac38","user":{"login":"aclamk","id":13020832,"avatar_url":"https://avatars.githubusercontent.com/u/13020832?v=3","gravatar_id":"","url":"https://api.github.com/users/aclamk","html_url":"https://github.com/aclamk","followers_url":"https://api.github.com/users/aclamk/followers","following_url":"https://api.github.com/users/aclamk/following{/other_user}","gists_url":"https://api.github.com/users/aclamk/gists{/gist_id}","starred_url":"https://api.github.com/users/aclamk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclamk/subscriptions","organizations_url":"https://api.github.com/users/aclamk/orgs","repos_url":"https://api.github.com/users/aclamk/repos","events_url":"https://api.github.com/users/aclamk/events{/privacy}","received_events_url":"https://api.github.com/users/aclamk/received_events","type":"User","site_admin":false},"repo":{"id":44256784,"name":"ceph","full_name":"aclamk/ceph","owner":{"login":"aclamk","id":13020832,"avatar_url":"https://avatars.githubusercontent.com/u/13020832?v=3","gravatar_id":"","url":"https://api.github.com/users/aclamk","html_url":"https://github.com/aclamk","followers_url":"https://api.github.com/users/aclamk/followers","following_url":"https://api.github.com/users/aclamk/following{/other_user}","gists_url":"https://api.github.com/users/aclamk/gists{/gist_id}","starred_url":"https://api.github.com/users/aclamk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclamk/subscriptions","organizations_url":"https://api.github.com/users/aclamk/orgs","repos_url":"https://api.github.com/users/aclamk/repos","events_url":"https://api.github.com/users/aclamk/events{/privacy}","received_events_url":"https://api.github.com/users/aclamk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aclamk/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":true,"url":"https://api.github.com/repos/aclamk/ceph","forks_url":"https://api.github.com/repos/aclamk/ceph/forks","keys_url":"https://api.github.com/repos/aclamk/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aclamk/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aclamk/ceph/teams","hooks_url":"https://api.github.com/repos/aclamk/ceph/hooks","issue_events_url":"https://api.github.com/repos/aclamk/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/aclamk/ceph/events","assignees_url":"https://api.github.com/repos/aclamk/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/aclamk/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/aclamk/ceph/tags","blobs_url":"https://api.github.com/repos/aclamk/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aclamk/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aclamk/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/aclamk/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aclamk/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/aclamk/ceph/languages","stargazers_url":"https://api.github.com/repos/aclamk/ceph/stargazers","contributors_url":"https://api.github.com/repos/aclamk/ceph/contributors","subscribers_url":"https://api.github.com/repos/aclamk/ceph/subscribers","subscription_url":"https://api.github.com/repos/aclamk/ceph/subscription","commits_url":"https://api.github.com/repos/aclamk/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/aclamk/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/aclamk/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/aclamk/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/aclamk/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/aclamk/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aclamk/ceph/merges","archive_url":"https://api.github.com/repos/aclamk/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aclamk/ceph/downloads","issues_url":"https://api.github.com/repos/aclamk/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/aclamk/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/aclamk/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/aclamk/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aclamk/ceph/labels{/name}","releases_url":"https://api.github.com/repos/aclamk/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/aclamk/ceph/deployments","created_at":"2015-10-14T15:21:53Z","updated_at":"2016-02-18T09:11:36Z","pushed_at":"2016-03-24T08:27:52Z","git_url":"git://github.com/aclamk/ceph.git","ssh_url":"git@github.com:aclamk/ceph.git","clone_url":"https://github.com/aclamk/ceph.git","svn_url":"https://github.com/aclamk/ceph","homepage":"http://ceph.com","size":165121,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ceph:master","ref":"master","sha":"518c238fbf66a851f3bfcd40b56fb381c259d5d9","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":2310495,"name":"ceph","full_name":"ceph/ceph","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":false,"url":"https://api.github.com/repos/ceph/ceph","forks_url":"https://api.github.com/repos/ceph/ceph/forks","keys_url":"https://api.github.com/repos/ceph/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph/teams","hooks_url":"https://api.github.com/repos/ceph/ceph/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph/events","assignees_url":"https://api.github.com/repos/ceph/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph/tags","blobs_url":"https://api.github.com/repos/ceph/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph/subscription","commits_url":"https://api.github.com/repos/ceph/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph/merges","archive_url":"https://api.github.com/repos/ceph/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph/downloads","issues_url":"https://api.github.com/repos/ceph/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/ceph/ceph/deployments","created_at":"2011-09-01T21:41:26Z","updated_at":"2016-03-29T14:32:18Z","pushed_at":"2016-03-29T15:02:41Z","git_url":"git://github.com/ceph/ceph.git","ssh_url":"git@github.com:ceph/ceph.git","clone_url":"https://github.com/ceph/ceph.git","svn_url":"https://github.com/ceph/ceph","homepage":"http://ceph.com","size":209735,"stargazers_count":2002,"watchers_count":2002,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1207,"mirror_url":null,"open_issues_count":296,"forks":1207,"open_issues":296,"watchers":2002,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/7693"},"html":{"href":"https://github.com/ceph/ceph/pull/7693"},"issue":{"href":"https://api.github.com/repos/ceph/ceph/issues/7693"},"comments":{"href":"https://api.github.com/repos/ceph/ceph/issues/7693/comments"},"review_comments":{"href":"https://api.github.com/repos/ceph/ceph/pulls/7693/comments"},"review_comment":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ceph/ceph/pulls/7693/commits"},"statuses":{"href":"https://api.github.com/repos/ceph/ceph/statuses/6733bde8b7acd1dc4888cb2d613a409f763eac38"}}}}