{"action":"created","issue":{"url":"https://api.github.com/repos/serverless/serverless/issues/4198","repository_url":"https://api.github.com/repos/serverless/serverless","labels_url":"https://api.github.com/repos/serverless/serverless/issues/4198/labels{/name}","comments_url":"https://api.github.com/repos/serverless/serverless/issues/4198/comments","events_url":"https://api.github.com/repos/serverless/serverless/issues/4198/events","html_url":"https://github.com/serverless/serverless/pull/4198","id":254884441,"number":4198,"title":"Added possibility to alias commands.","user":{"login":"HyperBrain","id":5524702,"avatar_url":"https://avatars3.githubusercontent.com/u/5524702?v=4","gravatar_id":"","url":"https://api.github.com/users/HyperBrain","html_url":"https://github.com/HyperBrain","followers_url":"https://api.github.com/users/HyperBrain/followers","following_url":"https://api.github.com/users/HyperBrain/following{/other_user}","gists_url":"https://api.github.com/users/HyperBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/HyperBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyperBrain/subscriptions","organizations_url":"https://api.github.com/users/HyperBrain/orgs","repos_url":"https://api.github.com/users/HyperBrain/repos","events_url":"https://api.github.com/users/HyperBrain/events{/privacy}","received_events_url":"https://api.github.com/users/HyperBrain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-03T16:20:36Z","updated_at":"2017-09-04T00:27:18Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/serverless/serverless/pulls/4198","html_url":"https://github.com/serverless/serverless/pull/4198","diff_url":"https://github.com/serverless/serverless/pull/4198.diff","patch_url":"https://github.com/serverless/serverless/pull/4198.patch"},"body":"## This is still work in progress! Watch out for changes of the PR description.\r\n\r\n## What did you implement:\r\n\r\nCloses #4172 \r\n\r\n## How did you implement it:\r\n\r\n* **Command alias support**\r\nCommands now support an alias array that let's them define an alias through which the command can be invoked alternatively. The pluginManager will build an command alias map, that contains all defined aliases with their specific targets.\r\nAliases are simply defined by adding an `aliases` array to any command, that specifies the command path that will invoke the command as alias, e.g. `install:plugin` would expose the command containing the alias as `serverless install plugin`.\r\nAliases appear with `serverless help` with the same description as their original commands.\r\n\r\n* **Error detection**\r\nThe pluginManager will now detect if aliases are specified somewhere and checks for the following restrictions:\r\n  * Aliases cannot overwrite commands and vice versa.\r\n  * Aliases cannot overwrite other aliases\r\n\r\n* Added debug logging on command/plugin load time (when SLS_DEBUG is set)\r\n\r\n## How can we verify it:\r\n\r\nAdd an alias to any command like this:\r\n```\r\ndeploy:\r\n  ...\r\n  commands: {\r\n    function: {\r\n      usage: 'Deploy a single function from the service',\r\n      lifecycleEvents: [\r\n        'initialize',\r\n        'packageFunction',\r\n        'deploy',\r\n      ],\r\n      aliases: [\r\n        'function:deploy',\r\n      ],\r\n      options: {\r\n        function: {\r\n          usage: 'Name of the function',\r\n          shortcut: 'f',\r\n          required: true,\r\n        },\r\n  ...\r\n```\r\nThis sample will expose the `deploy function` command additionally as `function deploy`.\r\n\r\n`serverless help` should show `function deploy` now as available command.\r\n\r\nInvocation of `serverless` should fail, if you set the alias to an existing command, so you're aware of the error immediately when implementing commands or changing their configuration.\r\nBTW: The unit tests check for all possible error cases.\r\n\r\n## Todos:\r\n\r\n- [x] Write tests\r\n- [ ] Write documentation\r\n- [x] Fix linting errors\r\n- [x] Make sure code coverage hasn't dropped\r\n- [x] Provide verification config / commands / resources\r\n- [x] Enable \"Allow edits from maintainers\" for this PR\r\n- [x] Update the messages below\r\n\r\n***Is this ready for review?:*** YES\r\n***Is it a breaking change?:*** NO\r\n"},"comment":{"url":"https://api.github.com/repos/serverless/serverless/issues/comments/326842245","html_url":"https://github.com/serverless/serverless/pull/4198#issuecomment-326842245","issue_url":"https://api.github.com/repos/serverless/serverless/issues/4198","id":326842245,"user":{"login":"HyperBrain","id":5524702,"avatar_url":"https://avatars3.githubusercontent.com/u/5524702?v=4","gravatar_id":"","url":"https://api.github.com/users/HyperBrain","html_url":"https://github.com/HyperBrain","followers_url":"https://api.github.com/users/HyperBrain/followers","following_url":"https://api.github.com/users/HyperBrain/following{/other_user}","gists_url":"https://api.github.com/users/HyperBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/HyperBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyperBrain/subscriptions","organizations_url":"https://api.github.com/users/HyperBrain/orgs","repos_url":"https://api.github.com/users/HyperBrain/repos","events_url":"https://api.github.com/users/HyperBrain/events{/privacy}","received_events_url":"https://api.github.com/users/HyperBrain/received_events","type":"User","site_admin":false},"created_at":"2017-09-04T00:27:18Z","updated_at":"2017-09-04T00:27:18Z","author_association":"MEMBER","body":"@pmuens @horike37 The command aliases are fully functional and unit tested now. \r\nHowever, I did not add them to the plugin author's guide, because I think that needs a rewrite anyway, as it currently is only a very high level documentation that even lacks entrypoint documentation."}}
{"actor":{"display_login":"HyperBrain"}}