/** * Command constructor. * * @param CLImate $climate */ public function __construct(CLImate $climate) { $this->climate = $climate; $this->createCommandLineArguments(); $this->climate->description(self::DESCRIPTION); $this->climate->arguments->parse(); if ($this->climate->arguments->defined('help')) { $this->climate->usage(); exit; } if ($this->climate->arguments->defined('list')) { $this->showList(); exit; } $config_file = $this->climate->arguments->defined('config') ? $this->climate->arguments->get('config') : self::DEFAULT_CONFIG; if (!file_exists($config_file)) { die("Couldn't read configuration file. Make sure the path is correct."); } $this->prepareConfig($config_file); }
/** * Register available options. */ protected function build() { $this->cli->description('PHPloy - Incremental Git FTP/SFTP deployment tool that supports multiple servers, submodules and rollbacks.'); $this->cli->arguments->add(['list' => ['prefix' => 'l', 'longPrefix' => 'list', 'description' => 'Lists the files and directories to be uploaded or deleted', 'noValue' => true], 'server' => ['prefix' => 's', 'longPrefix' => 'server', 'description' => 'Deploy to the given server'], 'rollback' => ['longPrefix' => 'rollback', 'description' => 'Rolls the deployment back to a given version', 'defaultValue' => 'HEAD^'], 'sync' => ['longPrefix' => 'sync', 'description' => 'Syncs revision to a given version', 'defaultValue' => 'LAST'], 'submodules' => ['prefix' => 'm', 'longPrefix' => 'submodules', 'description' => 'Includes submodules in next deployment', 'noValue' => true], 'init' => ['longPrefix' => 'init', 'description' => 'Creates sample deploy.ini file', 'noValue' => true], 'all' => ['longPrefix' => 'all', 'description' => 'Deploys to all specified servers when a default exists', 'noValue' => true], 'debug' => ['prefix' => 'd', 'longPrefix' => 'debug', 'description' => 'Shows verbose output for debugging', 'noValue' => true], 'version' => ['prefix' => 'v', 'longPrefix' => 'version', 'description' => 'Shows PHPloy version', 'noValue' => true], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Lists commands and their usage', 'noValue' => true]]); }