{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/14057","labels_url":"https://api.github.com/repos/symfony/symfony/issues/14057/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14057/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/14057/events","html_url":"https://github.com/symfony/symfony/pull/14057","id":64313059,"number":14057,"title":"[RFC][Console] Added console style guide helpers (v2)","user":{"login":"kbond","id":127811,"avatar_url":"https://avatars.githubusercontent.com/u/127811?v=3","gravatar_id":"","url":"https://api.github.com/users/kbond","html_url":"https://github.com/kbond","followers_url":"https://api.github.com/users/kbond/followers","following_url":"https://api.github.com/users/kbond/following{/other_user}","gists_url":"https://api.github.com/users/kbond/gists{/gist_id}","starred_url":"https://api.github.com/users/kbond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbond/subscriptions","organizations_url":"https://api.github.com/users/kbond/orgs","repos_url":"https://api.github.com/users/kbond/repos","events_url":"https://api.github.com/users/kbond/events{/privacy}","received_events_url":"https://api.github.com/users/kbond/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-03-25T16:30:58Z","updated_at":"2015-03-31T14:44:56Z","closed_at":"2015-03-30T15:51:31Z","pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/14057","html_url":"https://github.com/symfony/symfony/pull/14057","diff_url":"https://github.com/symfony/symfony/pull/14057.diff","patch_url":"https://github.com/symfony/symfony/pull/14057.patch"},"body":"*(Rebased to 2.7)*\r\n\r\n| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #12014, #12035, symfony/symfony-docs#4265\r\n| License       | MIT\r\n| Doc PR        | todo\r\n\r\n## Proposed API\r\n\r\n### Code\r\n\r\n```php\r\n// Symfony command\r\nprotected function execute(InputInterface $input, OutputInterface $output)\r\n{\r\n    $output = new SymfonyStyle($output);\r\n\r\n    $output->title('Lorem Ipsum Dolor Sit Amet');\r\n    $output->text(array(\r\n        'Duis aute irure dolor in reprehenderit in voluptate velit esse',\r\n        'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat'\r\n    ));\r\n    $output->ln();\r\n\r\n    $output->table(array('Name', 'Method', 'Scheme', 'Host', 'Path'), array(\r\n            array('admin_post_new', 'ANY', 'ANY', 'ANY', '/admin/post/new'),\r\n            array('admin_post_show', 'GET', 'ANY', 'ANY', '/admin/post/{id}'),\r\n            array('admin_post_edit', 'ANY', 'ANY', 'ANY', '/admin/post/{id}/edit'),\r\n            array('admin_post_delete', 'DELETE', 'ANY', 'ANY', '/admin/post/{id}'),\r\n        ));\r\n\r\n    $output->caution(array(\r\n            'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.',\r\n            'foo'\r\n        ));\r\n    $output->section('Consectetur Adipisicing Elit Sed Do Eiusmod');\r\n    $output->listing(array(\r\n        'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod, tempor incididunt ut labore et dolore magna aliqua.',\r\n        'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo.',\r\n        'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'\r\n    ));\r\n\r\n    $customValidator = function ($value) {\r\n        if ($value == 'foo') {\r\n            throw new \\Exception('cannot be foo');\r\n        }\r\n\r\n        return $value;\r\n    };\r\n\r\n    // hidden question\r\n    $output->note($output->askHidden('Hidden question'));\r\n\r\n    // choice questions\r\n    $output->note($output->choice('Choice question no default', array('choice1', 'choice2')));\r\n    $output->note($output->choice('Choice question with default', array('choice1', 'choice2'), 'choice1'));\r\n\r\n    // confirmation questions\r\n    $output->note($output->confirm('Confirmation with yes default', true) ? 'yes' : 'no');\r\n    $output->note($output->confirm('Confirmation with no default', false) ? 'yes' : 'no');\r\n\r\n    // standard questions\r\n    $output->note($output->ask('Question no default'));\r\n    $output->note($output->ask('Question no default and custom validator', null, $customValidator));\r\n    $output->note($output->ask('Question with default', 'default'));\r\n    $output->note($output->ask('Question with default and custom validator', 'default', $customValidator));\r\n\r\n    $output->note('Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.');\r\n    $output->success('Lorem ipsum dolor sit amet, consectetur adipisicing elit');\r\n    $output->error('Duis aute irure dolor in reprehenderit in voluptate velit esse.');\r\n    $output->warning('Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi.');\r\n\r\n    $output->progressStart(100);\r\n\r\n    for ($i = 0; $i < 100; $i++) {\r\n        usleep(10000);\r\n        $output->progressAdvance();\r\n    }\r\n\r\n    $output->progressFinish();\r\n}\r\n```\r\n\r\n### Output\r\n\r\n```\r\n$ php app/console command\r\n\r\nLorem Ipsum Dolor Sit Amet\r\n==========================\r\n\r\n // Duis aute irure dolor in reprehenderit in voluptate velit esse\r\n // cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat\r\n\r\n ------------------- -------- -------- ------ ----------------------- \r\n  Name                Method   Scheme   Host   Path                   \r\n ------------------- -------- -------- ------ ----------------------- \r\n  admin_post_new      ANY      ANY      ANY    /admin/post/new        \r\n  admin_post_show     GET      ANY      ANY    /admin/post/{id}       \r\n  admin_post_edit     ANY      ANY      ANY    /admin/post/{id}/edit  \r\n  admin_post_delete   DELETE   ANY      ANY    /admin/post/{id}       \r\n ------------------- -------- -------- ------ -----------------------\r\n\r\n ! [CAUTION] Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et    \r\n ! dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris. Lorem ipsum dolor sit amet, \r\n ! consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim    \r\n ! veniam, quis nostrud exercitation ullamco laboris.                                                                   \r\n !                                                                                                                      \r\n ! foo                                                                                                                  \r\n\r\nConsectetur Adipisicing Elit Sed Do Eiusmod\r\n-------------------------------------------\r\n\r\n * Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod, tempor incididunt ut labore et dolore magna aliqua.\r\n\r\n * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo.\r\n\r\n * Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\r\n\r\nHidden question:\r\n > <f><o><o><enter>\r\n\r\n ! [NOTE] foo\r\n\r\n Choice question no default:\r\n  [0] choice1\r\n  [1] choice2\r\n > <enter>\r\n\r\n [ERROR] Value \"\" is invalid                                                                                            \r\n\r\n Choice question no default:\r\n  [0] choice1\r\n  [1] choice2\r\n > 0<enter>\r\n\r\n ! [NOTE] choice1                                                                                                       \r\n\r\n Choice question with default [choice1]:\r\n  [0] choice1\r\n  [1] choice2\r\n > 1<enter>\r\n\r\n ! [NOTE] choice2                                                                                                       \r\n\r\n Confirmation with yes default (yes/no) [yes]:\r\n > <enter>\r\n\r\n ! [NOTE] yes                                                                                                           \r\n\r\n Confirmation with no default (yes/no) [no]:\r\n > <enter>\r\n\r\n ! [NOTE] no                                                                                                            \r\n\r\n Question no default:\r\n > <enter>\r\n\r\n [ERROR] A value is required.                                                                                           \r\n\r\n Question no default:\r\n > foo<enter>\r\n\r\n ! [NOTE] foo                                                                                                           \r\n\r\n Question no default and custom validator:\r\n > foo<enter>\r\n\r\n [ERROR] cannot be foo                                                                                                  \r\n\r\n Question no default and custom validator:\r\n > <enter>\r\n\r\n [ERROR] A value is required.                                                                                           \r\n\r\n Question no default and custom validator:\r\n > foo<enter>\r\n\r\n [ERROR] cannot be foo                                                                                                  \r\n\r\n Question no default and custom validator:\r\n > bar<enter>\r\n\r\n ! [NOTE] bar                                                                                                           \r\n\r\n Question with default [default]:\r\n > <enter>\r\n\r\n ! [NOTE] default                                                                                                       \r\n\r\n Question with default and custom validator [default]:\r\n > <enter>\r\n\r\n ! [NOTE] default                                                                                                       \r\n\r\n ! [NOTE] Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.        \r\n ! Excepteur sint occaecat cupidatat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu   \r\n ! fugiat nulla pariatur. Excepteur sint occaecat cupidatat. Duis aute irure dolor in reprehenderit in voluptate velit  \r\n ! esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.                                      \r\n\r\n [OK] Lorem ipsum dolor sit amet, consectetur adipisicing elit                                                          \r\n\r\n [ERROR] Duis aute irure dolor in reprehenderit in voluptate velit esse.                                                \r\n\r\n [WARNING] Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi.    \r\n\r\n 100/100 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\r\n                                 \r\n```\r\n\r\n### Screenshots\r\n\r\n![screen1](https://cloud.githubusercontent.com/assets/127811/4507077/53bc009c-4b09-11e4-937c-44fe7fe30dc0.png)\r\n\r\n![screen2](https://cloud.githubusercontent.com/assets/127811/4507078/53bf982e-4b09-11e4-8b5a-8c44c20ae4d9.png)\r\n\r\n![screen](https://cloud.githubusercontent.com/assets/127811/6848451/b2e64848-d3a3-11e4-9916-43bd377684ca.png)\r\n"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/88116095","html_url":"https://github.com/symfony/symfony/pull/14057#issuecomment-88116095","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14057","id":88116095,"user":{"login":"WouterJ","id":749025,"avatar_url":"https://avatars.githubusercontent.com/u/749025?v=3","gravatar_id":"","url":"https://api.github.com/users/WouterJ","html_url":"https://github.com/WouterJ","followers_url":"https://api.github.com/users/WouterJ/followers","following_url":"https://api.github.com/users/WouterJ/following{/other_user}","gists_url":"https://api.github.com/users/WouterJ/gists{/gist_id}","starred_url":"https://api.github.com/users/WouterJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WouterJ/subscriptions","organizations_url":"https://api.github.com/users/WouterJ/orgs","repos_url":"https://api.github.com/users/WouterJ/repos","events_url":"https://api.github.com/users/WouterJ/events{/privacy}","received_events_url":"https://api.github.com/users/WouterJ/received_events","type":"User","site_admin":false},"created_at":"2015-03-31T14:44:56Z","updated_at":"2015-03-31T14:44:56Z","body":"I would prefer if you could write some documentation about this nice feature (the style thing looks like a nice addition) in a new article called components/console/styles.html or so."}}