-
Notifications
You must be signed in to change notification settings - Fork 190
/
drush.php
69 lines (61 loc) · 1.7 KB
/
drush.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
use \Terminus\Dispatcher,
\Terminus\Utils,
\Terminus\CommandWithSSH;
class Drush_Command extends CommandWithSSH {
/**
* Invoke `drush` commands on a Pantheon development site
*
* <commands>...
* : The Drush commands you intend to run.
*
* [--<flag>=<value>]
* : Additional Drush flag(s) to pass in to the command.
*
* --site=<site>
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke( $args, $assoc_args ) {
$site_name = $assoc_args['site'];
if (isset($assoc_args['environment'])) {
$environment = $assoc_args['environment'];
}
else {
$environment = 'dev';
}
$site = $this->fetch_site($site_name);
if (!$site) {
Terminus::error("Command could not be completed.");
exit;
}
$server = Array(
'user' => "$environment.$site->site_uuid",
'host' => "appserver.$environment.$site->site_uuid.drush.in",
'port' => '2222'
);
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['environment'])) {
unset($assoc_args['environment']);
}
# Create user-friendly output
$command = implode( $args, ' ' );
$flags = '';
foreach ( $assoc_args as $k => $v ) {
if (isset($v) && (string) $v != '') {
$flags .= "--$k=$v";
}
else {
$flags .= "--$k";
}
}
Terminus::line( "Running drush $command $flags on $site_name-$environment" );
$this->send_command($server, 'drush', $args, $assoc_args );
}
}
Terminus::add_command( 'drush', 'Drush_Command' );