Skip to content

Commit

Permalink
Show a few more api commands and better debug output. (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash authored Jun 30, 2020
1 parent 465f1bd commit 6db06d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Command/Api/ApiListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ApiListCommand extends CommandBase {
* {inheritdoc}.
*/
protected function configure() {
$this->setDescription('List all commands in the api namespace')
$this->setDescription("<fg=cyan>There are more hidden API commands! Run api:list to see them all.</>")
->setAliases(['api']);
}

Expand All @@ -28,7 +28,7 @@ protected function configure() {
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output) {
// Unhide api:* commands.
// Un-hide api:* commands.
$api_commands = $this->getApplication()->all('api');
foreach ($api_commands as $api_command) {
$api_command->setHidden(FALSE);
Expand Down
15 changes: 8 additions & 7 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,29 +384,30 @@ public function promptChooseFromObjects($items, $unique_property, $label_propert
}

/**
* Load local project info from the ACLI datastore. If none exists, create default info and set it.
* Load local project info from the datastore. If none exists, create default info and set it.
* @throws \Exception
*/
protected function loadLocalProjectInfo() {
$this->logger->debug('Loading local project information...');
$local_user_config = $this->acliDatastore->get($this->acliConfigFilename);
// Save empty local project info.
// @todo Abstract this.
if ($local_user_config !== NULL && $this->repoRoot !== NULL) {
$this->logger->debug('Searching local datastore for matching project...');
foreach ($local_user_config['localProjects'] as $project) {
if ($project['directory'] === $this->repoRoot) {
$this->logger->debug('Matching local project found.');
if (array_key_exists('cloud_application_uuid', $project)) {
$this->logger->debug('Cloud application UUID: ' . $project['cloud_application_uuid']);
}
$this->localProjectInfo = $project;
return;
}
}
}
else {
$this->logger->debug('No matching local project found.');
$local_user_config = [];
}

// Save empty local project info.
// @todo Abstract this.
$this->logger->debug('No matching local project found.');
$local_user_config = [];
if ($this->repoRoot) {
$this->createLocalProjectStubInConfig($local_user_config);
}
Expand Down
18 changes: 17 additions & 1 deletion src/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$all_commands = $this->getApplication()->all();
foreach ($all_commands as $command) {
if (strpos($command->getName(), 'api:') !== FALSE && $command->getName() !== 'api:list') {
$command->setHidden(TRUE);
if (!in_array($command->getName(), $this->getUnhiddenApiCommands(), TRUE)) {
$command->setHidden(TRUE);
}
}
}
}
Expand All @@ -34,4 +36,18 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return 0;
}

/**
* Show a few of the api commands! Give people a sense of what's there.
*
* @return array
*/
protected function getUnhiddenApiCommands(): array {
return [
'api:accounts:find',
'api:environments:code-deploy',
'api:environments:database-backup-create',
'api:environments:domain-clear-varnish',
];
}

}

0 comments on commit 6db06d9

Please sign in to comment.