Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1][Console][Request] Style Guide helpers #8306

Closed
barryvdh opened this issue Apr 7, 2015 · 1 comment
Closed

[5.1][Console][Request] Style Guide helpers #8306

barryvdh opened this issue Apr 7, 2015 · 1 comment

Comments

@barryvdh
Copy link
Contributor

barryvdh commented Apr 7, 2015

In Symfony 2.7, Style Guide helpers are added (see symfony/symfony#14057 and symfony/symfony@96b4210 )

This adds a StyleInterface with a few common helpers, similar to the helpers that Laravel currently adds.

Perhaps it would be a good idea to make a Laravel Style, that perhaps extends the Symfony one. The existing helper functions could be redirected to the Style ouput, new methods can also be directed to the style helper or be available as $style for example.

The OutputStyle also implements the OutputInterface, so the Output could be changed to the OutputStyle.

Pros:

  • Easier to use
  • Prettier ouput
  • Uniformity between commands
  • Leverage Symfony helpers/code
  • Interoperability with Symfony

Cons:

  • Some helpers have different signatures, so might give confusion.

Example:

    public function run(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = new LaravelStyle($output);
        return parent::run($input, $output);
    }

    public function ask($question, $default = null)
    {
        return $this->output ->ask($question, $default);
    }

Table with current/symfony helpers:

Symfony StyleInterface Laravel Command
title($message) n/a
section($message) n/a
listing(array $elements) n/a
text($message) line($string)
success($message) n/a
error($message) error($string)
warning($message) n/a
note($message) info($string)
caution($message) n/a
n/a comment($string)
n/a question($string)
table(array $headers, array $rows) table(array $headers, array $rows, $style = 'default')
ask($question, $default = null, $validator = null) ask($question, $default = null)
askHidden($question, $validator = null) secret($question, $fallback = true)
n/a askWithCompletion($question, array $choices, $default = null)
confirm($question, $default = true) confirm($question, $default = false)
choice($question, array $choices, $default = null) choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
newLine($count = 1) n/a
progressStart($max = 0) n/a
progressAdvance($step = 1) n/a
progressFinish() n/a

As this is for 5.1 (because only in Symfony 2.7), we could change the signatures perhaps, if it's worth the BC break. Otherwise keep the existing method signatures and make the style available for new helpers.

I could make a PR for this if wanted.

@barryvdh
Copy link
Contributor Author

barryvdh commented Apr 8, 2015

Replaced by #8338

@barryvdh barryvdh closed this as completed Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant