public function testOptionGroups() { ClearIce::addGroups(['group' => 'location', 'help' => 'Location options'], ['group' => 'testing', 'help' => 'Some testing options']); ClearIce::addOptions(array('short' => 'i', 'long' => 'input', 'has_value' => true, 'group' => 'location', 'help' => "specifies where the input files for the wiki are found."), array('short' => 'o', 'long' => 'output', 'has_value' => true, 'group' => 'location', "help" => "specifies where the wiki should be written to"), array('short' => 'v', 'long' => 'verbose', "help" => "displays detailed information about everything that happens"), array('short' => 'x', 'long' => 'create-default-index', 'has_value' => false, "help" => "creates a default index page which lists all the wiki pages in a sorted order"), array('short' => 'd', 'long' => 'some-very-long-option-indeed', 'has_value' => false, 'group' => 'testing', "help" => "an uneccesarily long option which is meant to to see if the wrapping of help lines actually works."), array('short' => 's', 'has_value' => false, 'group' => 'testing', "help" => "a short option only"), array('long' => 'lone-long-option', 'has_value' => false, 'group' => 'testing', "help" => "a long option only")); $helpMessage = ClearIce::getHelpMessage(); $this->assertEquals(file_get_contents('tests/data/help_groups.txt'), $helpMessage); }
public function testCommandInterface() { require __DIR__ . '/../code/ArbitraryCommand.php'; global $argv; $argv = array("test", "arbitrary", "--daemon"); vfsStream::setup('std'); ClearIce::reset(); ClearIce::setStreamUrl('output', vfsStream::url('std/output')); ClearIce::addCommands(array('command' => 'arbitrary', 'help' => 'an arbitrary command', 'class' => 'ArbitraryCommand')); ClearIce::addOptions('daemon'); ClearIce::parse(); $this->assertStringEqualsFile(vfsStream::url('std/output'), '{"daemon":true}'); }
public function setup() { ClearIce::reset(); ClearIce::addOptions(array('short' => 'i', 'long' => 'input', 'has_value' => true, 'help' => "specifies where the input files for the wiki are found."), array('short' => 'o', 'long' => 'output', 'has_value' => true, "help" => "specifies where the wiki should be written to"), array('short' => 'v', 'long' => 'verbose', "help" => "displays detailed information about everything that happens"), array('short' => 'x', 'long' => 'create-default-index', 'has_value' => false, "help" => "creates a default index page which lists all the wiki pages in a sorted order"), array('short' => 'd', 'long' => 'some-very-long-option-indeed', 'has_value' => false, "help" => "an uneccesarily long option which is meant to to see if the wrapping of help lines actually works."), array('short' => 's', 'has_value' => false, "help" => "a short option only"), array('long' => 'lone-long-option', 'has_value' => false, "help" => "a long option only")); }
public function setup() { ClearIce::reset(); ClearIce::addCommands(array('command' => 'init', 'help' => 'initialize a directory with the source files of the wiki'), array('command' => 'generate', 'help' => 'generate the data for a given directory and store it somewhere cool', 'usage' => 'generate --target=[TARGET]'), 'export'); ClearIce::addOptions(array('command' => 'init', 'short' => 'd', 'long' => 'directory', 'has_value' => true, 'help' => "specify the directory to be initialized"), array('command' => 'init', 'short' => 't', 'long' => 'title', 'has_value' => true, 'help' => "title of the new wiki to be initialized"), array('command' => 'generate', 'short' => 't', 'long' => 'target', 'has_value' => true, "help" => "specify where the generated wiki should be"), array('command' => 'export', 'short' => 'f', 'long' => 'format', "help" => "specify the format of the exported wiki"), array('short' => 'v', 'long' => 'verbose', 'has_value' => false, "help" => "display more information")); }
public function setUp() { parent::setUp(); \clearice\ClearIce::addOptions(['long' => 'has-default', 'default' => 'def', 'has_value' => true], ['long' => 'another-default', 'default' => 'def2', 'has_value' => true], ['long' => 'no-default']); }
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ require "vendor/autoload.php"; require __DIR__ . "/../src/globals.php"; use clearice\ClearIce; use yentu\Yentu; use ntentan\config\Config; ClearIce::addCommands(array('command' => 'import', 'help' => 'import the schema of an existing database'), array('command' => 'migrate', 'help' => 'run new migrations on the target database'), array('command' => 'init', 'help' => 'initialize the yentu directory'), array('command' => 'create', 'usage' => 'create [name] [options]..', 'help' => 'create a new migration'), array('command' => 'rollback', 'help' => 'rollback the previus migration which was run'), array('command' => 'status', 'help' => 'display the current status of the migrations')); ClearIce::addOptions(array('command' => 'import', 'short' => 'd', 'long' => 'skip-defaults', 'help' => 'do not import the default values of the columns'), array('command' => 'init', 'short' => 'i', 'long' => 'interractive', 'help' => 'initialize yentu interractively'), array('command' => 'init', 'short' => 'd', 'long' => 'driver', 'help' => 'database platform. Supports postgresql', 'has_value' => true), array('command' => 'init', 'short' => 'h', 'long' => 'host', 'help' => 'the hostname of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'p', 'long' => 'port', 'help' => 'the port of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'n', 'long' => 'dbname', 'help' => 'the name of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'u', 'long' => 'user', 'help' => 'the user name on the target database', 'has_value' => true), array('command' => 'init', 'short' => 'p', 'long' => 'password', 'help' => 'the passwrd of the user on the target database', 'has_value' => true)); ClearIce::addOptions(array('command' => 'migrate', 'long' => 'no-foreign-keys', 'help' => 'do not apply any database foriegn-key constraints'), array('command' => 'migrate', 'long' => 'only-foreign-keys', 'help' => 'apply only database foreign-key constraints (fails on errors)'), array('command' => 'migrate', 'long' => 'force-foreign-keys', 'help' => 'apply only database foreign-key constraints'), array('command' => 'migrate', 'long' => 'dump-queries', 'help' => 'just dump the query and perform no action'), array('command' => 'migrate', 'long' => 'dry', 'help' => 'perform a dry run. Do not alter the database in anyway'), array('command' => 'migrate', 'long' => 'default-schema', 'has_value' => true, 'help' => 'use this as the default schema for all migrations'), array('command' => 'migrate', 'long' => 'default-ondelete', 'help' => 'the default cascade action for foreign key deletes', 'has_value' => true), array('command' => 'migrate', 'long' => 'default-onupdate', 'help' => 'the default cascade action for foreign key updates', 'has_value' => true)); ClearIce::addCommands(array('command' => 'rollback', 'long' => 'default-schema', 'has_value' => true, 'help' => 'reverse only migrations in this default-schema')); ClearIce::addOptions(array('short' => 'y', 'long' => 'home', 'help' => 'specifies where the yentu configurations are found', 'has_value' => true), array('short' => 'v', 'long' => 'verbose', 'help' => 'set level of verbosity. high, mid, low and none', 'has_value' => true)); ClearIce::addOptions(array('long' => 'details', 'help' => 'show details of all migrations.', 'command' => 'status')); ClearIce::setDescription("Yentu Database Migrations\nVersion " . Yentu::getVersion()); ClearIce::setFootnote("Report bugs to jainooson@gmail.com"); ClearIce::setUsage("[command] [options]"); ClearIce::addHelp(); ClearIce::setStrict(true); $options = ClearIce::parse(); if (isset($options['verbose'])) { ClearIce::setOutputLevel($options['verbose']); } try { if (isset($options['__command__'])) { if (isset($options['home'])) { Yentu::setDefaultHome($options['home']); } $class = "\\yentu\\commands\\" . ucfirst($options['__command__']);
public function testMultiOptions() { global $argv; $argv = array("test.php", "--some-multi-option=one", "--some-multi-option=two", "-mthree"); ClearIce::addOptions(array('long' => 'some-multi-option', 'short' => 'm', 'multi' => true, 'has_value' => true)); $this->assertEquals(array('some-multi-option' => array('one', 'two', 'three')), ClearIce::parse()); }