{"action":"created","issue":{"url":"https://api.github.com/repos/python-cmd2/cmd2/issues/289","repository_url":"https://api.github.com/repos/python-cmd2/cmd2","labels_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/289/labels{/name}","comments_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/289/comments","events_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/289/events","html_url":"https://github.com/python-cmd2/cmd2/issues/289","id":301553442,"number":289,"title":"Remove support for abbreviated commands","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},"labels":[{"id":554473465,"url":"https://api.github.com/repos/python-cmd2/cmd2/labels/documentation","name":"documentation","color":"5319e7","default":false},{"id":324131052,"url":"https://api.github.com/repos/python-cmd2/cmd2/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"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},"assignees":[{"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}],"milestone":{"url":"https://api.github.com/repos/python-cmd2/cmd2/milestones/12","html_url":"https://github.com/python-cmd2/cmd2/milestone/12","labels_url":"https://api.github.com/repos/python-cmd2/cmd2/milestones/12/labels","id":3081028,"number":12,"title":"0.8.1","description":"Milestone for 0.8.1 release","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":0,"closed_issues":25,"state":"closed","created_at":"2018-02-01T13:32:27Z","updated_at":"2018-03-11T17:30:35Z","due_on":null,"closed_at":"2018-03-11T17:30:35Z"},"comments":6,"created_at":"2018-03-01T20:46:08Z","updated_at":"2018-05-22T02:13:55Z","closed_at":"2018-03-03T00:12:54Z","author_association":"MEMBER","body":"The ability to abbreviate commands has always seemed like an anti-feature.  The presence of good tab-completion of command names makes it completely unnecessary to allow for accepting abbreviated command names.  While accepting abbreviated command names can result in users accidentally doing something quite unintentional.  Supporting abbreviated commands significantly complicates other support for several other features and it has outright never worked in combination with multi line commands, which we have documented.\r\n\r\nThe ``cmd2.Cmd.abbrev`` attribute which supports abbreviated commands should be removed entirely.\r\n\r\nAssociated documentation, unit tests, and examples will all need to be updated and the CHANGELOG will need to adequately communicate this potentially breaking change."},"comment":{"url":"https://api.github.com/repos/python-cmd2/cmd2/issues/comments/390840832","html_url":"https://github.com/python-cmd2/cmd2/issues/289#issuecomment-390840832","issue_url":"https://api.github.com/repos/python-cmd2/cmd2/issues/289","id":390840832,"user":{"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},"created_at":"2018-05-22T02:13:55Z","updated_at":"2018-05-22T02:13:55Z","author_association":"MEMBER","body":"I think you could exactly replicate the abbreviation functionality in a new plugin which overrides `default(self, statement)`. `default()` is called when the command isn't recognized.\r\n\r\n```python\r\ndef default(self, statement)\r\n    newcommand = None\r\n    target = 'do_' + statement.command\r\n    if self.abbrev:  # accept shortened versions of commands\r\n        funcs = [func for func in self.keywords if func.startswith(target) and func not in self.multilineCommands]\r\n        if len(funcs) == 1:\r\n            newcommand = funcs[0]\r\n    if newcommand:\r\n        line = \"{} {}\".format(newcommand, statement.args)\r\n        self.onecmd_plus_hooks(line)\r\n    else:\r\n         self.poutput(\"Unknown command: {}\\n\".format(statement.raw)\r\n```\r\n\r\nSo let's say I had a command called \"process\", with a corresponding `do_process()` method. At the prompt, the user typed \"proc with some arguments\". `cmd2.Cmd` would not see a method called `do_proc()` and so would call `default()` instead. The new `default()` method I sketched out above, checks to see if `self.abbrev` is set, if so, it goes to find a method on the class that starts with \"do_proc\". Finding only a single method, `do_process()`, it creates a new command with the full name of the method, and then executes that command with the args entered by the user.\r\n\r\nI haven't run this code, let alone tested it, I just riffed it off the top of my head. You would have to mixin the new plugin class into your subclass of `cmd2.Cmd`, but other than that I don't think you would have to change any of your existing code.\r\n\r\n@alsast, if you would like to offer to be the maintainer of a new `cmd2-abbrev` plugin, I'd be happy to help you get it going."}}
{"actor":{"display_login":"kotfu"}}