{"action":"created","comment":{"url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/comments/182816672","pull_request_review_id":113693227,"id":182816672,"diff_hunk":"@@ -0,0 +1,66 @@\n+# coding=utf-8\n+\"\"\"\n+Imports the proper readline for the platform and provides utility functions for it\n+\"\"\"\n+import sys\n+\n+try:\n+    from enum34 import Enum\n+except ImportError:\n+    from enum import Enum\n+\n+# Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit)\n+try:\n+    import gnureadline as readline\n+except ImportError:\n+    # Try to import readline, but allow failure for convenience in Windows unit testing\n+    # Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows\n+    try:\n+        # noinspection PyUnresolvedReferences\n+        import readline\n+    except ImportError:  # pragma: no cover\n+        pass\n+\n+\n+class RlType(Enum):\n+    \"\"\"Readline library types we recognize\"\"\"\n+    GNU = 1\n+    PYREADLINE = 2\n+    NONE = 3\n+\n+\n+# Check what implementation of readline we are using\n+\n+rl_type = RlType.NONE\n+\n+# The order of this check matters since importing pyreadline will also show readline in the modules list\n+if 'pyreadline' in sys.modules:\n+    rl_type = RlType.PYREADLINE\n+\n+elif 'gnureadline' in sys.modules or 'readline' in sys.modules:\n+    rl_type = RlType.GNU\n+\n+    # Load the readline lib so we can access members of it\n+    import ctypes\n+    readline_lib = ctypes.CDLL(readline.__file__)\n+\n+\n+def rl_force_redisplay() -> None:\n+    \"\"\"\n+    Causes readline to redraw prompt and input line\n+    \"\"\"\n+    if not sys.stdout.isatty():\n+        return\n+\n+    if rl_type == RlType.GNU:  # pragma: no cover\n+        # rl_forced_update_display() is the proper way to redraw the prompt and line, but we\n+        # have to use ctypes to do it since Python's readline API does not wrap the function\n+        readline_lib.rl_forced_update_display()\n+\n+        # After manually updating the display, readline asks that rl_display_fixed be set to 1 for efficiency\n+        display_fixed = ctypes.c_int.in_dll(readline_lib, \"rl_display_fixed\")\n+        display_fixed.value = 1\n+\n+    elif rl_type == RlType.PYREADLINE:  # pragma: no cover","path":"cmd2/rl_utils.py","position":64,"original_position":64,"commit_id":"df09c85e8db95622820712f29228dac2dc049935","original_commit_id":"df09c85e8db95622820712f29228dac2dc049935","user":{"login":"tleonhardt","id":2812720,"avatar_url":"https://avatars1.githubusercontent.com/u/2812720?v=4","gravatar_id":"","url":"https://api.github.com/users/tleonhardt","html_url":"https://github.com/tleonhardt","followers_url":"https://api.github.com/users/tleonhardt/followers","following_url":"https://api.github.com/users/tleonhardt/following{/other_user}","gists_url":"https://api.github.com/users/tleonhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/tleonhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleonhardt/subscriptions","organizations_url":"https://api.github.com/users/tleonhardt/orgs","repos_url":"https://api.github.com/users/tleonhardt/repos","events_url":"https://api.github.com/users/tleonhardt/events{/privacy}","received_events_url":"https://api.github.com/users/tleonhardt/received_events","type":"User","site_admin":false},"body":"This is covered on Windows when the ``pyreadline`` module is installed, which is a conditional dependency on Windows so it should be.  So this should be covered by our AppVeyor CI builds.","created_at":"2018-04-19T16:59:00Z","updated_at":"2018-04-19T16:59:30Z","html_url":"https://github.com/python-cmd2/cmd2/pull/362#discussion_r182816672","pull_request_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/comments/182816672"},"html":{"href":"https://github.com/python-cmd2/cmd2/pull/362#discussion_r182816672"},"pull_request":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362"}}},"pull_request":{"url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362","id":182548636,"html_url":"https://github.com/python-cmd2/cmd2/pull/362","diff_url":"https://github.com/python-cmd2/cmd2/pull/362.diff","patch_url":"https://github.com/python-cmd2/cmd2/pull/362.patch","issue_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/362","number":362,"state":"open","locked":false,"title":"Autocompleter","user":{"login":"anselor","id":17968842,"avatar_url":"https://avatars0.githubusercontent.com/u/17968842?v=4","gravatar_id":"","url":"https://api.github.com/users/anselor","html_url":"https://github.com/anselor","followers_url":"https://api.github.com/users/anselor/followers","following_url":"https://api.github.com/users/anselor/following{/other_user}","gists_url":"https://api.github.com/users/anselor/gists{/gist_id}","starred_url":"https://api.github.com/users/anselor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anselor/subscriptions","organizations_url":"https://api.github.com/users/anselor/orgs","repos_url":"https://api.github.com/users/anselor/repos","events_url":"https://api.github.com/users/anselor/events{/privacy}","received_events_url":"https://api.github.com/users/anselor/received_events","type":"User","site_admin":false},"body":"This PR addresses most of the feature described in #349 and adds examples and unit tests exercising the new features.\r\nIn a future round of changes, cmd2 will be updated to automatically use AutoCompleter for completion on all argparse-driven commands (unless overridden with a custom completion function)","created_at":"2018-04-18T17:23:39Z","updated_at":"2018-04-19T16:59:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38c4770475cdeede932155a648dc9c90373fa01d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"kotfu","id":218536,"avatar_url":"https://avatars1.githubusercontent.com/u/218536?v=4","gravatar_id":"","url":"https://api.github.com/users/kotfu","html_url":"https://github.com/kotfu","followers_url":"https://api.github.com/users/kotfu/followers","following_url":"https://api.github.com/users/kotfu/following{/other_user}","gists_url":"https://api.github.com/users/kotfu/gists{/gist_id}","starred_url":"https://api.github.com/users/kotfu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kotfu/subscriptions","organizations_url":"https://api.github.com/users/kotfu/orgs","repos_url":"https://api.github.com/users/kotfu/repos","events_url":"https://api.github.com/users/kotfu/events{/privacy}","received_events_url":"https://api.github.com/users/kotfu/received_events","type":"User","site_admin":false},{"login":"kmvanbrunt","id":28899027,"avatar_url":"https://avatars1.githubusercontent.com/u/28899027?v=4","gravatar_id":"","url":"https://api.github.com/users/kmvanbrunt","html_url":"https://github.com/kmvanbrunt","followers_url":"https://api.github.com/users/kmvanbrunt/followers","following_url":"https://api.github.com/users/kmvanbrunt/following{/other_user}","gists_url":"https://api.github.com/users/kmvanbrunt/gists{/gist_id}","starred_url":"https://api.github.com/users/kmvanbrunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmvanbrunt/subscriptions","organizations_url":"https://api.github.com/users/kmvanbrunt/orgs","repos_url":"https://api.github.com/users/kmvanbrunt/repos","events_url":"https://api.github.com/users/kmvanbrunt/events{/privacy}","received_events_url":"https://api.github.com/users/kmvanbrunt/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":324131052,"url":"https://api.github.com/repos/python-cmd2/cmd2/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":324180637,"url":"https://api.github.com/repos/python-cmd2/cmd2/labels/major","name":"major","color":"fbca04","default":false}],"milestone":{"url":"https://api.github.com/repos/python-cmd2/cmd2/milestones/17","html_url":"https://github.com/python-cmd2/cmd2/milestone/17","labels_url":"https://api.github.com/repos/python-cmd2/cmd2/milestones/17/labels","id":3260913,"number":17,"title":"0.9.0","description":"First release to only support Python 3","creator":{"login":"tleonhardt","id":2812720,"avatar_url":"https://avatars1.githubusercontent.com/u/2812720?v=4","gravatar_id":"","url":"https://api.github.com/users/tleonhardt","html_url":"https://github.com/tleonhardt","followers_url":"https://api.github.com/users/tleonhardt/followers","following_url":"https://api.github.com/users/tleonhardt/following{/other_user}","gists_url":"https://api.github.com/users/tleonhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/tleonhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleonhardt/subscriptions","organizations_url":"https://api.github.com/users/tleonhardt/orgs","repos_url":"https://api.github.com/users/tleonhardt/repos","events_url":"https://api.github.com/users/tleonhardt/events{/privacy}","received_events_url":"https://api.github.com/users/tleonhardt/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":7,"state":"open","created_at":"2018-04-12T06:18:41Z","updated_at":"2018-04-18T22:11:52Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362/commits","review_comments_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362/comments","review_comment_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/362/comments","statuses_url":"https://api.github.com/repos/python-cmd2/cmd2/statuses/df09c85e8db95622820712f29228dac2dc049935","head":{"label":"python-cmd2:autocompleter","ref":"autocompleter","sha":"df09c85e8db95622820712f29228dac2dc049935","user":{"login":"python-cmd2","id":17161025,"avatar_url":"https://avatars1.githubusercontent.com/u/17161025?v=4","gravatar_id":"","url":"https://api.github.com/users/python-cmd2","html_url":"https://github.com/python-cmd2","followers_url":"https://api.github.com/users/python-cmd2/followers","following_url":"https://api.github.com/users/python-cmd2/following{/other_user}","gists_url":"https://api.github.com/users/python-cmd2/gists{/gist_id}","starred_url":"https://api.github.com/users/python-cmd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-cmd2/subscriptions","organizations_url":"https://api.github.com/users/python-cmd2/orgs","repos_url":"https://api.github.com/users/python-cmd2/repos","events_url":"https://api.github.com/users/python-cmd2/events{/privacy}","received_events_url":"https://api.github.com/users/python-cmd2/received_events","type":"Organization","site_admin":false},"repo":{"id":51442999,"name":"cmd2","full_name":"python-cmd2/cmd2","owner":{"login":"python-cmd2","id":17161025,"avatar_url":"https://avatars1.githubusercontent.com/u/17161025?v=4","gravatar_id":"","url":"https://api.github.com/users/python-cmd2","html_url":"https://github.com/python-cmd2","followers_url":"https://api.github.com/users/python-cmd2/followers","following_url":"https://api.github.com/users/python-cmd2/following{/other_user}","gists_url":"https://api.github.com/users/python-cmd2/gists{/gist_id}","starred_url":"https://api.github.com/users/python-cmd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-cmd2/subscriptions","organizations_url":"https://api.github.com/users/python-cmd2/orgs","repos_url":"https://api.github.com/users/python-cmd2/repos","events_url":"https://api.github.com/users/python-cmd2/events{/privacy}","received_events_url":"https://api.github.com/users/python-cmd2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-cmd2/cmd2","description":"cmd2 - Quickly build feature-rich and user-friendly interactive command line applications in Python","fork":false,"url":"https://api.github.com/repos/python-cmd2/cmd2","forks_url":"https://api.github.com/repos/python-cmd2/cmd2/forks","keys_url":"https://api.github.com/repos/python-cmd2/cmd2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-cmd2/cmd2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-cmd2/cmd2/teams","hooks_url":"https://api.github.com/repos/python-cmd2/cmd2/hooks","issue_events_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/events{/number}","events_url":"https://api.github.com/repos/python-cmd2/cmd2/events","assignees_url":"https://api.github.com/repos/python-cmd2/cmd2/assignees{/user}","branches_url":"https://api.github.com/repos/python-cmd2/cmd2/branches{/branch}","tags_url":"https://api.github.com/repos/python-cmd2/cmd2/tags","blobs_url":"https://api.github.com/repos/python-cmd2/cmd2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-cmd2/cmd2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-cmd2/cmd2/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-cmd2/cmd2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-cmd2/cmd2/statuses/{sha}","languages_url":"https://api.github.com/repos/python-cmd2/cmd2/languages","stargazers_url":"https://api.github.com/repos/python-cmd2/cmd2/stargazers","contributors_url":"https://api.github.com/repos/python-cmd2/cmd2/contributors","subscribers_url":"https://api.github.com/repos/python-cmd2/cmd2/subscribers","subscription_url":"https://api.github.com/repos/python-cmd2/cmd2/subscription","commits_url":"https://api.github.com/repos/python-cmd2/cmd2/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-cmd2/cmd2/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-cmd2/cmd2/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-cmd2/cmd2/contents/{+path}","compare_url":"https://api.github.com/repos/python-cmd2/cmd2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-cmd2/cmd2/merges","archive_url":"https://api.github.com/repos/python-cmd2/cmd2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-cmd2/cmd2/downloads","issues_url":"https://api.github.com/repos/python-cmd2/cmd2/issues{/number}","pulls_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls{/number}","milestones_url":"https://api.github.com/repos/python-cmd2/cmd2/milestones{/number}","notifications_url":"https://api.github.com/repos/python-cmd2/cmd2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-cmd2/cmd2/labels{/name}","releases_url":"https://api.github.com/repos/python-cmd2/cmd2/releases{/id}","deployments_url":"https://api.github.com/repos/python-cmd2/cmd2/deployments","created_at":"2016-02-10T13:34:49Z","updated_at":"2018-04-18T22:07:18Z","pushed_at":"2018-04-19T16:49:30Z","git_url":"git://github.com/python-cmd2/cmd2.git","ssh_url":"git@github.com:python-cmd2/cmd2.git","clone_url":"https://github.com/python-cmd2/cmd2.git","svn_url":"https://github.com/python-cmd2/cmd2","homepage":"http://cmd2.readthedocs.io/","size":2963,"stargazers_count":102,"watchers_count":102,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":20,"open_issues":9,"watchers":102,"default_branch":"master"}},"base":{"label":"python-cmd2:master","ref":"master","sha":"7560b0a92bb2050d137e53d56a8e2aaa8ba69cd0","user":{"login":"python-cmd2","id":17161025,"avatar_url":"https://avatars1.githubusercontent.com/u/17161025?v=4","gravatar_id":"","url":"https://api.github.com/users/python-cmd2","html_url":"https://github.com/python-cmd2","followers_url":"https://api.github.com/users/python-cmd2/followers","following_url":"https://api.github.com/users/python-cmd2/following{/other_user}","gists_url":"https://api.github.com/users/python-cmd2/gists{/gist_id}","starred_url":"https://api.github.com/users/python-cmd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-cmd2/subscriptions","organizations_url":"https://api.github.com/users/python-cmd2/orgs","repos_url":"https://api.github.com/users/python-cmd2/repos","events_url":"https://api.github.com/users/python-cmd2/events{/privacy}","received_events_url":"https://api.github.com/users/python-cmd2/received_events","type":"Organization","site_admin":false},"repo":{"id":51442999,"name":"cmd2","full_name":"python-cmd2/cmd2","owner":{"login":"python-cmd2","id":17161025,"avatar_url":"https://avatars1.githubusercontent.com/u/17161025?v=4","gravatar_id":"","url":"https://api.github.com/users/python-cmd2","html_url":"https://github.com/python-cmd2","followers_url":"https://api.github.com/users/python-cmd2/followers","following_url":"https://api.github.com/users/python-cmd2/following{/other_user}","gists_url":"https://api.github.com/users/python-cmd2/gists{/gist_id}","starred_url":"https://api.github.com/users/python-cmd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-cmd2/subscriptions","organizations_url":"https://api.github.com/users/python-cmd2/orgs","repos_url":"https://api.github.com/users/python-cmd2/repos","events_url":"https://api.github.com/users/python-cmd2/events{/privacy}","received_events_url":"https://api.github.com/users/python-cmd2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-cmd2/cmd2","description":"cmd2 - Quickly build feature-rich and user-friendly interactive command line applications in Python","fork":false,"url":"https://api.github.com/repos/python-cmd2/cmd2","forks_url":"https://api.github.com/repos/python-cmd2/cmd2/forks","keys_url":"https://api.github.com/repos/python-cmd2/cmd2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-cmd2/cmd2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-cmd2/cmd2/teams","hooks_url":"https://api.github.com/repos/python-cmd2/cmd2/hooks","issue_events_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/events{/number}","events_url":"https://api.github.com/repos/python-cmd2/cmd2/events","assignees_url":"https://api.github.com/repos/python-cmd2/cmd2/assignees{/user}","branches_url":"https://api.github.com/repos/python-cmd2/cmd2/branches{/branch}","tags_url":"https://api.github.com/repos/python-cmd2/cmd2/tags","blobs_url":"https://api.github.com/repos/python-cmd2/cmd2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-cmd2/cmd2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-cmd2/cmd2/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-cmd2/cmd2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-cmd2/cmd2/statuses/{sha}","languages_url":"https://api.github.com/repos/python-cmd2/cmd2/languages","stargazers_url":"https://api.github.com/repos/python-cmd2/cmd2/stargazers","contributors_url":"https://api.github.com/repos/python-cmd2/cmd2/contributors","subscribers_url":"https://api.github.com/repos/python-cmd2/cmd2/subscribers","subscription_url":"https://api.github.com/repos/python-cmd2/cmd2/subscription","commits_url":"https://api.github.com/repos/python-cmd2/cmd2/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-cmd2/cmd2/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-cmd2/cmd2/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-cmd2/cmd2/contents/{+path}","compare_url":"https://api.github.com/repos/python-cmd2/cmd2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-cmd2/cmd2/merges","archive_url":"https://api.github.com/repos/python-cmd2/cmd2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-cmd2/cmd2/downloads","issues_url":"https://api.github.com/repos/python-cmd2/cmd2/issues{/number}","pulls_url":"https://api.github.com/repos/python-cmd2/cmd2/pulls{/number}","milestones_url":"https://api.github.com/repos/python-cmd2/cmd2/milestones{/number}","notifications_url":"https://api.github.com/repos/python-cmd2/cmd2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-cmd2/cmd2/labels{/name}","releases_url":"https://api.github.com/repos/python-cmd2/cmd2/releases{/id}","deployments_url":"https://api.github.com/repos/python-cmd2/cmd2/deployments","created_at":"2016-02-10T13:34:49Z","updated_at":"2018-04-18T22:07:18Z","pushed_at":"2018-04-19T16:49:30Z","git_url":"git://github.com/python-cmd2/cmd2.git","ssh_url":"git@github.com:python-cmd2/cmd2.git","clone_url":"https://github.com/python-cmd2/cmd2.git","svn_url":"https://github.com/python-cmd2/cmd2","homepage":"http://cmd2.readthedocs.io/","size":2963,"stargazers_count":102,"watchers_count":102,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":20,"open_issues":9,"watchers":102,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362"},"html":{"href":"https://github.com/python-cmd2/cmd2/pull/362"},"issue":{"href":"https://api.github.com/repos/python-cmd2/cmd2/issues/362"},"comments":{"href":"https://api.github.com/repos/python-cmd2/cmd2/issues/362/comments"},"review_comments":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362/comments"},"review_comment":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-cmd2/cmd2/pulls/362/commits"},"statuses":{"href":"https://api.github.com/repos/python-cmd2/cmd2/statuses/df09c85e8db95622820712f29228dac2dc049935"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"tleonhardt"}}