8000 [RFC][Console] Added console style guide helpers by kbond · Pull Request #12035 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC][Console] Added console style guide helpers #12035

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

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
8000
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix cs
  • Loading branch information
kbond committed Oct 2, 2014
commit 5428b2ece5e513a8be9beecca15eea59d0a1fe4c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* Decorates output to add console style guide helper methods
* Decorates output to add console style guide helpers
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Console\Style\FormatterInterface;

/**
* Formats a list element
* Formats a list element.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
Expand Down
E864
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Component\Console\Style\AbstractOutputStyle;

/**
* Output decorator helpers for the Symfony Style Guide.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
class StandardOutputStyle extends AbstractOutputStyle
Expand Down Expand Up @@ -53,7 +55,7 @@ public function block($messages, $type = null, $style = null, $prefix = ' ')
}

/**
* Formats a command title
* Formats a command title.
*
* @param string $message
*/
Expand All @@ -63,7 +65,7 @@ public function title($message)
}

/**
* Formats a section title
* Formats a section title.
*
* @param string $message
*/
Expand All @@ -73,7 +75,7 @@ public function section($message)
}

/**
* Formats a list
* Formats a list.
*
* @param array $elements
*/
Expand All @@ -83,7 +85,7 @@ public function listing(array $elements)
}

/**
* Formats informational text
* Formats informational text.
*
* @param string|array $messages
*/
Expand All @@ -93,7 +95,7 @@ public function text($messages)
}

/**
* Formats a success result bar
* Formats a success result bar.
*
* @param string|array $messages
*/
Expand All @@ -103,7 +105,7 @@ public function success($messages)
}

/**
* Formats an error result bar
* Formats an error result bar.
*
* @param string|array $messages
*/
Expand All @@ -113,7 +115,7 @@ public function error($messages)
}

/**
* Formats an warning result bar
* Formats an warning result bar.
*
* @param string|array $messages
*/
Expand All @@ -123,7 +125,7 @@ public function warning($messages)
}

/**
* Formats a note admonition
* Formats a note admonition.
*
* @param string|array $messages
*/
Expand All @@ -133,7 +135,7 @@ public function note($messages)
}

/**
* Formats a caution admonition
* Formats a caution admonition.
*
* @param string|array $messages
*/
Expand All @@ -143,7 +145,7 @@ public function caution($messages)
}

/**
* Formats a table
* Formats a table.
*
* @param array $headers
* @param array $rows
Expand All @@ -160,7 +162,7 @@ public function table(array $headers, array $rows)
}

/**
* Asks a question
* Asks a question.
*
* @param string $question
* @param string|null $default
Expand All @@ -177,7 +179,7 @@ public function ask($question, $default = null, $validator = null)
}

/**
* Asks a question with the user input hidden
* Asks a question with the user input hidden.
*
* @param string $question
* @param callable|null $validator
Expand All @@ -193,7 +195,7 @@ public function askHidden($question, $validator = null)
}

/**
* Asks for confirmation
* Asks for confirmation.
*
* @param string $question
* @param bool $default
Expand All @@ -206,7 +208,7 @@ public function confirm($question, $default = true)
}

/**
* Asks a choice question
* Asks a choice question.
*
* @param string $question
* @param array $choices
Expand All @@ -224,6 +226,23 @@ public function choice($question, array $choices, $default = null)
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
}

/**
* Asks a choice question.
*
* @param string $question
* @param array $choices
* @param array $default
*
* @return string
*/
public function multipleChoice($question, array $choices, array $default = array())
{
$question = new ChoiceQuestion($question, $choices, $default);
$question->setMultiselect(true);

return $this->askQuestion($question);
}

/**
* @param Question $question
*
Expand All @@ -238,4 +257,3 @@ public function askQuestion(Question $question)
return $ret;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Symfony\Component\Console\Question\Question;

/**
* Symfony Style Guide compliant question helper.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
class StandardQuestionHelper extends QuestionHelper
Expand All @@ -35,7 +37,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu
}

// make required
if (!is_bool($value) && 0 === strlen($value)) {
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
throw new \Exception('A value is required.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Console\Style\FormatterInterface;

/**
* Formats informational text
* Formats informational text.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Console\Style\FormatterInterface;

/**
* Formats a command title
* Formats a command title.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
Expand Down
0