2017 © Pedro Peláez
 

library console-option-resolver

Library to ask questions for missing options and arguments

image

wjzijderveld/console-option-resolver

Library to ask questions for missing options and arguments

  • Sunday, November 30, 2014
  • by wjzijderveld
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Console options resolver

Build Status, (*1)

A simple library for Symfony Console., (*2)

It allows to ask the user for options if not provided, this way you can use a command both interactive as in a bash oneliner., (*3)

Installation

composer require wjzijderveld/console-input-resolver 1.*@dev

Usage

class GenerateCommand extends Command
{
    private $inputResolver;

    public function __construct(Resolver $inputResolver)
    {
        parent::__construct();

        $this->inputResolver = $inputResolver;
    }

    public function configure()
    {
        $this->setName('generate');

        $this
            ->addArgument('class', InputArgument::OPTIONAL, 'The name of the class to generate')
            ->addOption('namespace', null, InputOption::VALUE_REQUIRED, 'The namespace to generate the class in');
    }

    public function execut(InputInterface $input, OutputInterface $output)
    {
        // values will now contain values for namespace and class
        // for each option or argument that is not given when running this command
        // it will interactivily ask for a value
        $values = $this->inputResolver->resolveInputDefinition($this->getDefinition(), array('namespace', 'class'));

        var_dump($values);
    }
}

Example output:, (*4)

$ ./console generate --namespace Acme
> The name of the class to generate: Foo
> array(2) {
  'namespace' =>
  string(4) "Acme"
  'class' =>
  string(3) "Foo"
}

The Versions

30/11 2014

dev-master

9999999-dev

Library to ask questions for missing options and arguments

  Sources   Download

MIT

The Requires

 

The Development Requires

by Willem-Jan Zijderveld

30/11 2014

0.2.0

0.2.0.0

Library to ask questions for missing options and arguments

  Sources   Download

MIT

The Requires

 

The Development Requires

by Willem-Jan Zijderveld

30/11 2014

0.1.0

0.1.0.0

Library to ask questions for missing options

  Sources   Download

MIT

The Requires

 

The Development Requires

by Willem-Jan Zijderveld