{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/6499","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/6499/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/6499/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/6499/events","html_url":"https://github.com/cakephp/cakephp/issues/6499","id":73628206,"number":6499,"title":"RFC - Console macros","user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/console","name":"console","color":"FFFFFF"},{"url":"https://api.github.com/repos/cakephp/cakephp/labels/Enhancement","name":"Enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/cakephp/cakephp/labels/RFC","name":"RFC","color":"c7def8"}],"state":"open","locked":false,"assignee":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/31","html_url":"https://github.com/cakephp/cakephp/milestones/3.1.0","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/31/labels","id":919718,"number":31,"title":"3.1.0","description":"Backwards compatible with 3.0.x. Will require PHP 5.5\r\n\r\n### Specific issues\r\n\r\n* Adding the exception trace to the error view data. #6000 \r\n* Changed the translate behavior to support translation engines. #5958 \r\n* Database connection prefixes, or table prefixes.","creator":{"login":"lorenzo","id":37621,"avatar_url":"https://avatars.githubusercontent.com/u/37621?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzo","html_url":"https://github.com/lorenzo","followers_url":"https://api.github.com/users/lorenzo/followers","following_url":"https://api.github.com/users/lorenzo/following{/other_user}","gists_url":"https://api.github.com/users/lorenzo/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzo/subscriptions","organizations_url":"https://api.github.com/users/lorenzo/orgs","repos_url":"https://api.github.com/users/lorenzo/repos","events_url":"https://api.github.com/users/lorenzo/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzo/received_events","type":"User","site_admin":false},"open_issues":50,"closed_issues":51,"state":"open","created_at":"2015-01-02T15:38:07Z","updated_at":"2015-05-15T02:19:38Z","due_on":"2015-07-26T04:00:00Z","closed_at":null},"comments":10,"created_at":"2015-05-06T13:53:01Z","updated_at":"2015-05-17T13:40:04Z","closed_at":null,"body":"Creating reusable blocks of console output code is not easy right now, and with a few improvements we can provide a simple, extensible API for building console output macros. [CLImate](http://climate.thephpleague.com/terminal-objects/table/) is a good example of how I think this could be approached.\r\n\r\n## Console Macro classes\r\n\r\nConsole macros would be simple classes that implement an ``output`` method. The arguments to this method would depend on the macro object, and no interface would be enforced. Macro classes would be accessed from the `ConsoleIo` instance that all shells have access to:\r\n\r\n```php\r\n// In a shell or task\r\n$this->_io->macro('table', $headers, $rows);\r\n\r\n// or via __call\r\n$this->_io->table($headers, $rows);\r\n```\r\n\r\nUnder the hood the `macro` does the following:\r\n\r\n* Uses the ConsoleMacroRegistry to locate the macro class.\r\n* The class of the macro would be expected to be `App\\Shell\\Macro\\${name}Macro`.\r\n* An instance would be created with the current ConsoleIo instance and added to the registry.\r\n* The instance's `output()` method would be called.\r\n\r\n### Built in Macros\r\n\r\nWe could provide a small selection of macros to start with and expand as the community needs more. To start with I propose:\r\n\r\n* Table - Create well formatted tables. This is already needed in the RouteShell.\r\n* Progress - Create single line progress bars.\r\n\r\n### Macro Conventions\r\n\r\n* Macros would live in `App\\Shell\\Macro` and have the `Macro` suffix.\r\n* Macros need to implement `output($args)`\r\n* Macros get the ConsoleIo instance in their constructor.\r\n"},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/102804925","html_url":"https://github.com/cakephp/cakephp/issues/6499#issuecomment-102804925","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/6499","id":102804925,"user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"created_at":"2015-05-17T13:40:04Z","updated_at":"2015-05-17T13:40:04Z","body":"I'm ok with ShellHelper. So we would end up with\r\n\r\n```php\r\nnamespace App\\Shell\\ShellHelper;\r\n\r\nclass TableShellHelper extends ShellHelper\r\n{}\r\n\r\n$this->_io->helper('table', $stuff);\r\n$this->_io->table($stuff);\r\n```\r\n\r\nDoes that seem decent?"}}