From 0aba549e7f11e1035fa7a2e880803b47cbadd919 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sun, 1 Sep 2013 16:40:50 +0200 Subject: Use more object oriented way for console commands --- core/command/status.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/command/status.php (limited to 'core') diff --git a/core/command/status.php b/core/command/status.php new file mode 100644 index 00000000000..601780257e4 --- /dev/null +++ b/core/command/status.php @@ -0,0 +1,30 @@ +setName('status') + ->setDescription('show some status information') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $values = array( + 'installed' => \OC_Config::getValue('installed') ? 'true' : 'false', + 'version' => implode('.', \OC_Util::getVersion()), + 'versionstring' => \OC_Util::getVersionString(), + 'edition' => \OC_Util::getEditionString()); + print_r($values); + } +} -- cgit v1.2.3 From 44b3e71ed4e1beb3e815def7ac9bd9848039fb84 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 2 Sep 2013 18:20:04 +0200 Subject: Cleanup and more style fixes --- console.php | 1 - core/command/status.php | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/console.php b/console.php index 11df7eb0dc9..2f773cc6a1a 100644 --- a/console.php +++ b/console.php @@ -7,7 +7,6 @@ * See the COPYING-README file. */ -use OC\Core\Command\GreetCommand; use Symfony\Component\Console\Application; $RUNTIME_NOAPPS = true; diff --git a/core/command/status.php b/core/command/status.php index 601780257e4..2bd89919dd5 100644 --- a/core/command/status.php +++ b/core/command/status.php @@ -8,23 +8,21 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class Status extends Command -{ - protected function configure() - { +class Status extends Command { + protected function configure() { $this ->setName('status') ->setDescription('show some status information') ; } - protected function execute(InputInterface $input, OutputInterface $output) - { + protected function execute(InputInterface $input, OutputInterface $output) { $values = array( 'installed' => \OC_Config::getValue('installed') ? 'true' : 'false', 'version' => implode('.', \OC_Util::getVersion()), 'versionstring' => \OC_Util::getVersionString(), - 'edition' => \OC_Util::getEditionString()); + 'edition' => \OC_Util::getEditionString(), + ); print_r($values); } } -- cgit v1.2.3 From 666bbbe06085451c12e4e55b886703e823eabf07 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 13 Sep 2013 18:10:04 +0200 Subject: Use appinfo/register_command.php to add commands to the console command --- apps/files/appinfo/register_command.php | 9 +++++++++ console.php | 9 +++++++-- core/register_command.php | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 apps/files/appinfo/register_command.php create mode 100644 core/register_command.php (limited to 'core') diff --git a/apps/files/appinfo/register_command.php b/apps/files/appinfo/register_command.php new file mode 100644 index 00000000000..435ce0ab23f --- /dev/null +++ b/apps/files/appinfo/register_command.php @@ -0,0 +1,9 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +$application->add(new OCA\Files\Command\Scan(OC_User::getManager())); diff --git a/console.php b/console.php index 2f773cc6a1a..30f4b729214 100644 --- a/console.php +++ b/console.php @@ -25,6 +25,11 @@ if (!OC::$CLI) { $defaults = new OC_Defaults; $application = new Application($defaults->getName(), \OC_Util::getVersionString()); -$application->add(new OC\Core\Command\Status); -$application->add(new OCA\Files\Command\Scan(OC_User::getManager())); +require_once 'core/register_command.php'; +foreach(OC_App::getEnabledApps() as $app) { + $file = OC_App::getAppPath($app).'/appinfo/register_command.php'; + if(file_exists($file)) { + require $file; + } +} $application->run(); diff --git a/core/register_command.php b/core/register_command.php new file mode 100644 index 00000000000..1eed347b7b5 --- /dev/null +++ b/core/register_command.php @@ -0,0 +1,9 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +$application->add(new OC\Core\Command\Status); -- cgit v1.2.3 From a9ea99e93d0dc982b5daa3ed7974e5bd419dcd1b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 19 Sep 2013 19:12:16 +0200 Subject: Add copyright, remove starting blank line --- apps/files/command/scan.php | 7 +++++++ console.php | 1 - core/command/status.php | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index c5631d19561..25ab70af362 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -1,4 +1,11 @@ + * Copyright (c) 2013 Bart Visscher + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ namespace OCA\Files\Command; diff --git a/console.php b/console.php index b8dd5e08790..25b8b312539 100644 --- a/console.php +++ b/console.php @@ -1,4 +1,3 @@ - diff --git a/core/command/status.php b/core/command/status.php index 2bd89919dd5..ea9825b0f61 100644 --- a/core/command/status.php +++ b/core/command/status.php @@ -1,4 +1,10 @@ + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ namespace OC\Core\Command; -- cgit v1.2.3