Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ public function __construct(
The order of the fields is significant. A leading - in the field indicates
the field should be sorted in a descending order. Not all fields are sortable.'
),
new InputOption(
'format',
null,
InputOption::VALUE_REQUIRED,
'The output format (txt or json)',
'txt'
),
]
);

Expand Down
7 changes: 5 additions & 2 deletions src/Commands/AccountCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ class AccountCommand extends AcquiaCommand
*/
public function account(Config $config, Account $accountAdapter)
{
$account = $accountAdapter->get();

if ($this->input()->getOption('format') === 'json') {
return $this->writeln(json_encode($account));
}

$extraConfig = $config->get('extraconfig');
$tz = $extraConfig['timezone'];
$format = $extraConfig['format'];
$timezone = new \DateTimeZone($tz);

$account = $accountAdapter->get();

$lastLogin = new \DateTime($account->last_login_at);
$lastLogin->setTimezone($timezone);
$createdAt = new \DateTime($account->created_at);
Expand Down
7 changes: 7 additions & 0 deletions src/Commands/DomainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function domainList(OutputInterface $output, Domains $domainAdapter, $uui
{
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);
$domains = $domainAdapter->getAll($environment->uuid);
if ($this->input()->getOption('format') === 'json') {
return $this->writeln(json_encode($domains));
}

$table = new Table($output);
$table->setHeaders(['Hostname', 'Default', 'Active', 'Uptime']);
Expand Down Expand Up @@ -68,6 +71,10 @@ public function domainInfo(OutputInterface $output, Domains $domainAdapter, $uui
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);
$domain = $domainAdapter->status($environment->uuid, $domain);

if ($this->input()->getOption('format') === 'json') {
return $this->writeln(json_encode($domain));
}

$table = new Table($output);
$table->setHeaders(['Hostname', 'Active', 'DNS Resolves', 'IP Addresses', 'CNAMES']);
$table->setColumnStyle(1, 'center-align');
Expand Down