diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-11-11 04:44:39 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-11-11 04:44:39 +0400 |
commit | 225998cbfa9435fbd42edb6b474cc0ca2bd56337 (patch) | |
tree | 260b33ad454dfa7f8d22d805c8a156dd6862a46d /plugins/ExampleCommand/Commands | |
parent | 085c55f95f0d5b95549dec9daca7e7ff9d81d4ab (diff) |
refs #4241 added example command
Diffstat (limited to 'plugins/ExampleCommand/Commands')
-rw-r--r-- | plugins/ExampleCommand/Commands/HelloWorld.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/ExampleCommand/Commands/HelloWorld.php b/plugins/ExampleCommand/Commands/HelloWorld.php new file mode 100644 index 0000000000..92f543609f --- /dev/null +++ b/plugins/ExampleCommand/Commands/HelloWorld.php @@ -0,0 +1,43 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik_Plugins + * @package CoreConsole + */ + +namespace Piwik\Plugins\ExampleCommand\Commands; + +use Piwik\Plugin\ConsoleCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @package ExampleCommand + */ +class HelloWorld extends ConsoleCommand +{ + protected function configure() + { + $this->setName('examplecommand:helloworld'); + $this->setDescription('ExampleCommand'); + $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:'); + } + + /** + * Execute command like: ./console examplecommand:helloworld --name="The Piwik Team" + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getOption('name'); + + $message = sprintf('<info>HelloWorld: %s</info>', $name); + + $output->writeln($message); + } +}
\ No newline at end of file |