/** * Generates pestle command boiler plate * This command creates the necessary files * for a pestle command * * pestle.phar generate_pestle_command command_name * * @command generate_pestle_command * @argument command_name New Command Name? [foo_bar] * @argument namespace_module Create in PHP Namespace? [Pulsestorm\Magento2\Cli] */ function pestle_cli($argv) { $command_name = $argv['command_name']; $namespace = createNamespaceFromNamespaceAndCommandName($argv['namespace_module'], $command_name); $command = '<' . '?php' . "\n" . 'namespace ' . $namespace . ';' . "\n" . 'use function Pulsestorm\\Pestle\\Importer\\pestle_import;' . "\n" . 'pestle_import(\'Pulsestorm\\Pestle\\Library\\output\');' . "\n\n" . '/**' . "\n" . '* One Line Description' . "\n" . '*' . "\n" . '* @command ' . $command_name . '' . "\n" . '*/' . "\n" . 'function pestle_cli($argv)' . "\n" . '{' . "\n" . ' output("Hello Sailor");' . "\n" . '}' . "\n"; output("Creating the following module"); output($command); $path_full = createPathFromNamespace($namespace); if (file_exists($path_full)) { output("{$path_full} already exists, bailing"); exit; } writeStringToFile($path_full, $command); output("bbedit {$path_full}"); output("sublime {$path_full}"); output("vi {$path_full}"); }
public function testNamespaceGenerate3() { $path = createNamespaceFromNamespaceAndCommandName('Pulsestorm\\Magento2\\Cli', 'foo_science'); $this->assertEquals('Pulsestorm\\Magento2\\Cli\\Foo_Science', $path); }