Skip to content

Commit 1ebd6f9

Browse files
committed
Add a report function so customers can actually see what upstreams they are using
1 parent 65ca24b commit 1ebd6f9

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

php/commands/sites.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,44 @@ public function show($args, $assoc_args) {
5151
return $toReturn;
5252
}
5353

54+
/**
55+
* Create a site report
56+
*
57+
* ## OPTIONS
58+
*
59+
* [--fields=<field>] :
60+
* A comma-separated list of fields to include, to see available fields use ```terminus site info```
61+
*
62+
* [--filter=<field:value>] :
63+
* Specify a filter on field:value. For instance upstream:.*wordpress.* would filter for sites with upstreams matching wordpress
64+
*
65+
*/
66+
public function report($args, $assoc_args) {
67+
$sites = SiteFactory::instance();
68+
$data = array();
69+
foreach ($sites as $site) {
70+
$report = array(
71+
'name' => $site->getName(),
72+
);
73+
74+
$fields = Input::optional('fields', $assoc_args, false);
75+
if ($fields) {
76+
$fields = explode(',',$fields);
77+
foreach ($fields as $field) {
78+
$report[$field] = $site->info($field);
79+
}
80+
} else {
81+
$info = $site->info();
82+
foreach ($info as $key=>$value) {
83+
$report[$key] = $value;
84+
}
85+
}
86+
87+
$data[] = $report;
88+
}
89+
90+
$this->handleDisplay($data);
91+
}
5492
/**
5593
* Create a new site
5694
*
@@ -258,7 +296,6 @@ public function mass_update($args, $assoc_args) {
258296
$confirm = Input::optional('confirm', $assoc_args, false);
259297

260298
// Start status messages.
261-
Terminus::line('Starting mass-update.');
262299
if($upstream) Terminus::line('Looking for sites using '.$upstream.'.');
263300

264301
foreach( $sites as $site ) {
@@ -294,7 +331,7 @@ public function mass_update($args, $assoc_args) {
294331
Terminus::success("Backup of ".$site->getName()." created.");
295332
Terminus::line('Updating '.$site->getName().'.');
296333
// Apply the update, failure here would trigger a guzzle exception so no need to validate success.
297-
// $response = $site->applyUpstreamUpdates($env, $update, $xoption);
334+
$response = $site->applyUpstreamUpdates($env, $update, $xoption);
298335
$data[$site->getName()]['status'] = 'Updated';
299336
Terminus::success($site->getName().' is updated.');
300337
} else {

0 commit comments

Comments
 (0)