#!/usr/bin/env php <?php $autoloads = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'); foreach ($autoloads as $autoload) { $autoload = str_replace('/', DIRECTORY_SEPARATOR, $autoload); if (file_exists($autoload)) { require_once $autoload; } } /* define cli options */ $command = new \Commando\Command(); $command->setHelp("Usage: {$argv[0]} [OPTIONS] src dest\n\nChange directory structure or class name to fit the standard. \nThis tool scan src dir for class definations and put them to a new dir, other files are left.\nIt does not support namespace yet"); $command->argument()->require()->expectsFile()->title('src')->describedAs('src directory of your code'); $command->argument()->require()->title('dest')->describedAs('dest directory to generate code'); $command->option('s')->aka('standard')->describedAs('naming standard, avalible standards are: psr0, yaf_controller')->must(function ($standard) { $standards = array('psr0', 'yaf_controller'); return in_array($standard, $standards); }); $command->option('i')->aka('input')->describedAs("Regex to match input files, default is '/\\.php\$/'"); $command->option('t')->aka('target')->describedAs('if you want to rename class or method, specify target here: class, method')->must(function ($target) { $targets = array('class', 'method'); return in_array($target, $targets); }); $command->option('p')->aka('pattern')->describedAs('pattern to match your class name or method name'); $command->option('r')->aka('replace')->describedAs('replacement to replace your class or method name'); if ($command['t']) { $command->option('p')->require(); $command->option('r')->require(); } $command->parse(); /* do process */
<?php require dirname(__DIR__) . '/vendor/autoload.php'; // php file.php ./assets/example.txt $cmd = new Commando\Command(); $cmd->argument()->expectsFile(); var_dump($cmd->getArgumentValues());