GetPath.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Core\Command\App;
  23. use OC\Core\Command\Base;
  24. use Symfony\Component\Console\Input\InputArgument;
  25. use Symfony\Component\Console\Input\InputInterface;
  26. use Symfony\Component\Console\Output\OutputInterface;
  27. class GetPath extends Base {
  28. protected function configure() {
  29. parent::configure();
  30. $this
  31. ->setName('app:getpath')
  32. ->setDescription('Get an absolute path to the app directory')
  33. ->addArgument(
  34. 'app',
  35. InputArgument::REQUIRED,
  36. 'Name of the app'
  37. )
  38. ;
  39. }
  40. /**
  41. * Executes the current command.
  42. *
  43. * @param InputInterface $input An InputInterface instance
  44. * @param OutputInterface $output An OutputInterface instance
  45. * @return null|int null or 0 if everything went fine, or an error code
  46. */
  47. protected function execute(InputInterface $input, OutputInterface $output) {
  48. $appName = $input->getArgument('app');
  49. $path = \OC_App::getAppPath($appName);
  50. if ($path !== false) {
  51. $output->writeln($path);
  52. return 0;
  53. }
  54. // App not found, exit with non-zero
  55. return 1;
  56. }
  57. }