[Forwardport] Add MagentoStyle as Console Input/output helper object to allow easier access to io helpers in symfony/console #13741
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original Pull Requests
#11504
#13698
Description
Gives a helper object to access styling objects in symfony console easier.
How to use it
Instantiate inside a command object's methods (usually interact and execute but not limited to)
$io = new MagentoStyle($input,$output);Titles: Creates a title header with a double bar underline
$io->title("My Title");Sections: Creates a section header with a single bar underline
$io->section("My Section");Content Output:
Creates a text block
$io->text("Your message here");Creates a bulleted list
$io->listing(["item1","item2","item3"]);Creates a table
$io->table(["header1","header2","header3"],[ ["A","B","C"], ["D","E","F"], ["G","H","I"] ]);Prints a new line
$io->newLine();Admonition Methods: success, warning, caution, note, comment
Print out a padded and colored message
$io->success("You Win!");$io->error("You Fail!");Progress Bar
Creates an interactive progress bar
$io->progressStart(100);$io->progressAdvance(10);$io->progressFinish();Questions
$io->ask("What is your name?");$io->confirm("Are you sure?");$io->choice("What is your favorite color?",["red,"blue","yellow"]);Questions for missing arguments and options
$io->askForMissingArgument( $argument, $question, $default = null, $validator = null, $maxAttempts = null, $comment = null, $commentFormat = "Argument [%s] set to: %s" )$io->askForMissingOption( $option, $question, $default = null, $validator = null, $maxAttempts = null, $comment = null, $commentFormat = "Option [%s] set to: %s" )Contribution checklist