Changeset View
Changeset View
Standalone View
Standalone View
src/parser/argument/workflow/PhutilArgumentWorkflow.php
<?php | <?php | ||||
/** | /** | ||||
* Used with @{class:PhutilArgumentParser} to build command line tools which | * Used with @{class:PhutilArgumentParser} to build command line tools which | ||||
* operate in several modes, called "workflows", like `git`, `svn`, `arc`, | * operate in several modes, called "workflows", like `git`, `svn`, `arc`, | ||||
* `apt-get`. For example, you might build a simple calculator like this: | * `apt-get`. For example, you might build a simple calculator like this: | ||||
* | * | ||||
* name=scripts/example/calculator.php | * name=scripts/example/calculator.php | ||||
* $args = new PhutilArgumentParser($argv); | * $args = new PhutilArgumentParser($argv); | ||||
* $args->setTagline('simple calculator example'); | * $args->setTagline('simple calculator example'); | ||||
* $args->setSynopsis(<<<EOHELP | * $args->setSynopsis(<<<EOHELP | ||||
* **calculator.php** __op__ __n__ ... | * **calculator.php** __op__ __n__ ... | ||||
* Perform a calculation. | * Perform a calculation. | ||||
* EOHELP | * EOHELP | ||||
* ); | * ); | ||||
* | * | ||||
* $add_workflow = id(new PhutilArgumentWorkflow()) | * $add_workflow = (new PhutilArgumentWorkflow()) | ||||
* ->setName('add') | * ->setName('add') | ||||
* ->setExamples('**add** __n__ ...') | * ->setExamples('**add** __n__ ...') | ||||
* ->setSynopsis('Compute the sum of a list of numbers.') | * ->setSynopsis('Compute the sum of a list of numbers.') | ||||
* ->setArguments( | * ->setArguments( | ||||
* array( | * array( | ||||
* array( | * array( | ||||
* 'name' => 'numbers', | * 'name' => 'numbers', | ||||
* 'wildcard' => true, | * 'wildcard' => true, | ||||
* ), | * ), | ||||
* )); | * )); | ||||
* | * | ||||
* $mul_workflow = id(new PhutilArgumentWorkflow()) | * $mul_workflow = (new PhutilArgumentWorkflow()) | ||||
* ->setName('mul') | * ->setName('mul') | ||||
* ->setExamples('**mul** __n__ ...') | * ->setExamples('**mul** __n__ ...') | ||||
* ->setSynopsis('Compute the product of a list of numbers.') | * ->setSynopsis('Compute the product of a list of numbers.') | ||||
* ->setArguments( | * ->setArguments( | ||||
* array( | * array( | ||||
* array( | * array( | ||||
* 'name' => 'numbers', | * 'name' => 'numbers', | ||||
* 'wildcard' => true, | * 'wildcard' => true, | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0