protected function execute(InputInterface $input, OutputInterface $output) { $this->boot($input, $output); if ($input->getOption('out') === 'auto') { $hasReturn = preg_match('/^\\s*return[ \\t\\r\\n]/', $input->getArgument('code')) || preg_match('/[;\\{]\\s*return[ \\t\\r\\n]/', $input->getArgument('code')); $input->setOption('out', $hasReturn ? \Civi\Cv\Encoder::getDefaultFormat() : 'none'); } $value = eval($input->getArgument('code') . ';'); $this->sendResult($input, $output, $value); }
protected function configure() { $this->setName('api')->setDescription('Call an API')->addOption('in', NULL, InputOption::VALUE_REQUIRED, 'Input format (args,json)', 'args')->addOption('out', NULL, InputOption::VALUE_REQUIRED, 'Output format (' . implode(',', Encoder::getFormats()) . ')', Encoder::getDefaultFormat())->addArgument('Entity.action', InputArgument::REQUIRED)->addArgument('key=value', InputArgument::IS_ARRAY)->setHelp('Call an API Examples: cv api system.get cv api contact.get id=10 echo \'{"id":10, "api.Email.get": 1}\' | cv api contact.get --in=json NOTE: To change the default output format, set CV_OUTPUT. '); parent::configureBootOptions(); }
protected function configure() { $this->setName('url')->setDescription('Compose a URL to a CiviCRM page')->addArgument('path')->addOption('out', NULL, InputArgument::OPTIONAL, 'Specify return format (json,none,php,pretty,shell)', \Civi\Cv\Encoder::getDefaultFormat())->addOption('relative', 'r', InputOption::VALUE_NONE, 'Prefer relative URL format. (Default: absolute)')->addOption('frontend', 'f', InputOption::VALUE_NONE, 'Generate a frontend URL (Default: backend)')->addOption('open', 'O', InputOption::VALUE_NONE, 'Open a local web browser')->setHelp(' Compose a URL to a CiviCRM page Examples: cv url civicrm/dashboard cv url civicrm/dashboard --open cv url \'civicrm/a/#/mailing/123?angularDebug=1\' NOTE: To change the default output format, set CV_OUTPUT. '); parent::configureBootOptions(); }
protected function configure() { $this->setName('vars:show')->setDescription('Show the configuration of the local CiviCRM installation')->addOption('out', NULL, InputOption::VALUE_REQUIRED, 'Output format (' . implode(',', Encoder::getFormats()) . ')', Encoder::getDefaultFormat()); parent::configureBootOptions(); }