Skip to content

Conversation

@serhii-balko
Copy link
Owner

Original Pull Request

magento#11504
...to allow easier access to io helpers in symfony/console

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);

  1. Titles: Creates a title header with a double bar underline
    $io->title("My Title");

  2. Sections: Creates a section header with a single bar underline
    $io->section("My Section");

  3. 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();

  4. Admonition Methods: success, warning, caution, note, comment
    Print out a padded and colored message
    $io->success("You Win!");
    $io->error("You Fail!");

  5. Progress Bar
    Creates an interactive progress bar
    $io->progressStart(100);
    $io->progressAdvance(10);
    $io->progressFinish();

  6. Questions
    $io->ask("What is your name?");
    $io->confirm("Are you sure?");
    $io->choice("What is your favorite color?",["red,"blue","yellow"]);

  7. 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

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • [-] All new or changed code is covered with unit/integration tests (if applicable)
  • [-] All automated tests passed successfully (all builds on Travis CI are green)

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

Successfully merging this pull request may close these issues.

2 participants