wjzijderveld/console-option-resolver
最新稳定版本:0.2.0
Composer 安装命令:
composer require wjzijderveld/console-option-resolver
包简介
Library to ask questions for missing options and arguments
README 文档
README
A simple library for Symfony Console.
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.
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:
$ ./console generate --namespace Acme > The name of the class to generate: Foo > array(2) { 'namespace' => string(4) "Acme" 'class' => string(3) "Foo" }
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-29