11
0
Fork 0
mirror of https://github.com/n3w/helpers-cli-input.git synced 2025-12-19 12:43:23 +00:00

Updated example

This commit is contained in:
Alannah Kearney 2019-06-01 22:49:10 +10:00
commit 27c04d1d43

View file

@ -9,13 +9,13 @@ use pointybeard\Helpers\Functions\Cli;
// Define what we are expecting to get from the command line // Define what we are expecting to get from the command line
$collection = (new Input\InputCollection()) $collection = (new Input\InputCollection())
->append( ->add(
Input\InputTypeFactory::build('Argument') Input\InputTypeFactory::build('Argument')
->name('action') ->name('action')
->flags(Input\AbstractInputType::FLAG_REQUIRED) ->flags(Input\AbstractInputType::FLAG_REQUIRED)
->description('The name of the action to perform') ->description('The name of the action to perform')
) )
->append( ->add(
Input\InputTypeFactory::build('IncrementingFlag') Input\InputTypeFactory::build('IncrementingFlag')
->name('v') ->name('v')
->flags(Input\AbstractInputType::FLAG_OPTIONAL | Input\AbstractInputType::FLAG_TYPE_INCREMENTING) ->flags(Input\AbstractInputType::FLAG_OPTIONAL | Input\AbstractInputType::FLAG_TYPE_INCREMENTING)
@ -27,7 +27,7 @@ $collection = (new Input\InputCollection())
} }
)) ))
) )
->append( ->add(
Input\InputTypeFactory::build('LongOption') Input\InputTypeFactory::build('LongOption')
->name('data') ->name('data')
->short('d') ->short('d')
@ -90,7 +90,7 @@ echo Cli\manpage(
// -d, --data=VALUE Path to the input JSON data // -d, --data=VALUE Path to the input JSON data
// //
// Examples: // Examples:
// php -f example/example.php -- -vvvs -d example/example.json import // php -f example/example.php -- -vvv -d example/example.json import
var_dump($argv->find('action')); var_dump($argv->find('action'));
// string(6) "import" // string(6) "import"
@ -98,9 +98,6 @@ var_dump($argv->find('action'));
var_dump($argv->find('v')); var_dump($argv->find('v'));
//int(3) //int(3)
var_dump($argv->find('s'));
//bool(true)
var_dump($argv->find('data')); var_dump($argv->find('data'));
// class stdClass#11 (1) { // class stdClass#11 (1) {
// public $fruit => // public $fruit =>