private function getUsageHelp() { $commands = CommandLine\Commands::getInstance(); $out = "usage: %bphrozn%n %g<command>%n [options] [args]\n\n"; $out .= "Type 'phrozn help <command>' for help on a specific command.\n"; $out .= "Type 'phrozn ? help' for help on using help.\n"; $out .= "Type 'phrozn --version' to see the program version and installed plugins.\n"; $out .= "\nAvailable commands:\n"; $displayed = array(); // array of already displayed comands foreach ($commands as $name => $data) { if(isset($displayed[$name])) { continue; } $command = $data['command']; $out .= ' ' . $name; if (null !== $command['aliases']) { $out .= ' (' . implode(', ', $command['aliases']) . ')'; } $out .= "\n"; $displayed[$name] = $name; } return $out; }
/** * Fine tune main command by adding subcommands * * @para array $paths Paths to various Phrozn directories * @param array $config Loaded contents of phrozn.yml * * @return \Phrozn\Runner\Command */ private function configureCommand($paths, $config) { // options foreach ($config['command']['options'] as $name => $option) { $this->addOption($name, $option); } // commands $commands = CommandLine\Commands::getInstance()->setPath($paths['configs'] . 'commands'); foreach ($commands as $name => $data) { $this->registerCommand($name, $data); } return $this; }
private function getUsageHelp() { $commands = $this->sortCommands(CommandLine\Commands::getInstance()); $out = "usage: %bphrozn%n %g<command>%n [options] [args]\n\n"; $out .= "Type 'phrozn help <command>' for help on a specific command.\n"; $out .= "Type 'phrozn ? help' for help on using help.\n"; $out .= "Type 'phrozn --version' to see the program version and installed plugins.\n"; $out .= "\nAvailable commands:\n"; foreach ($commands as $name => $data) { $command = $data['command']; $out .= ' ' . $name; if (null !== $command['aliases']) { $out .= ' (' . implode(', ', $command['aliases']) . ')'; } $out .= "\n"; } return $out; }
/** * Search if an alias exists for this command * * @param string $file Command name (could be an alias) * @return string The real command file name * */ private function getRealCommandName($file) { $iter = CommandLine\Commands::getInstance(); $commands = array(); foreach ($iter as $name => $data) { $commands[$name] = $data; } ksort($commands); if (!file_exists($file)) { foreach ($commands as $command) { if (is_array($command["command"]["aliases"]) && in_array($file, $command["command"]["aliases"])) { return $command["command"]["name"]; } } } return $file; }