Ejemplo n.º 1
0
 public function testDefaultValues()
 {
     global $argv;
     $argv = array("test");
     $values = \clearice\ClearIce::parse();
     $this->assertEquals(['has-default' => 'def', 'another-default' => 'def2'], $values);
 }
Ejemplo n.º 2
0
 public function testStringCommandDeclaration()
 {
     global $argv;
     $argv = ['test', 'mycommand'];
     ClearIce::reset();
     ClearIce::setStreamUrl('output', vfsStream::url('std/output'));
     ClearIce::addCommands('mycommand');
     $options = ClearIce::parse();
     $this->assertEquals('mycommand', $options['__command__']);
 }
Ejemplo n.º 3
0
 function testHelpCommandUsage()
 {
     global $argv;
     $argv = array('test', 'help', 'generate');
     vfsStream::setup('std');
     $stdout = vfsStream::url('std/output');
     ClearIce::setStreamUrl('output', $stdout);
     ClearIce::setUsage("[input] [options]..");
     ClearIce::setDescription("Simple Wiki version 1.0\nA sample or should I say dummy wiki app to help explain ClearIce. This app practically does nothing.");
     ClearIce::setFootnote("Hope you had a nice time learning about ClearIce. We're pretty sure your cli apps would no longer be boring to work with.\n\nReport bugs to bugs@clearice.tld");
     ClearIce::addHelp();
     ClearIce::parse();
     $this->assertFileEquals('tests/data/help_for_command_usage.txt', vfsStream::url('std/output'));
 }
 public function testSkipping2()
 {
     global $argv;
     $argv = array('wiki', '--output', '-i', '/var/input');
     $this->assertEquals(array('output' => true, 'input' => '/var/input'), ClearIce::parse());
 }
Ejemplo n.º 5
0
Archivo: cli.php Proyecto: codogh/yentu
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__']);
        unset($options['__command__']);
        Config::readPath(Yentu::getPath('config'), 'yentu');
        $command = new $class();
        $command->run($options);
    } else {
        ClearIce::output(ClearIce::getHelpMessage());
Ejemplo n.º 6
0
 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());
 }