1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Schnittstabil\Dartisan\Commands; |
4
|
|
|
|
5
|
|
|
use Garden\Cli\Cli; |
6
|
|
|
|
7
|
|
|
trait DatabaseAwareCommandTrait |
8
|
|
|
{ |
9
|
|
|
protected static function registerDatabaseDriver(Cli $cli) |
10
|
|
|
{ |
11
|
|
|
return $cli->opt( |
12
|
|
|
'connection-driver', |
13
|
|
|
'The database driver to use, defaults to DB_DRIVER and "mysql"' |
14
|
|
|
)->opt( |
15
|
|
|
'connection-prefix', |
16
|
|
|
'The table prefix to use, defaults to DB_PREFIX and ""' |
17
|
|
|
)->opt( |
18
|
|
|
'connection-charset', |
19
|
|
|
'The character set to use, defaults to DB_CHARSET and "utf8"' |
20
|
|
|
); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected static function registerDatabaseConnection(Cli $cli) |
24
|
|
|
{ |
25
|
|
|
return $cli->opt( |
26
|
|
|
'connection-host', |
27
|
|
|
'The host to use, defaults to DB_HOST and "localhost"' |
28
|
|
|
)->opt( |
29
|
|
|
'connection-database', |
30
|
|
|
'The databse to use, defaults to DB_DATABASE and "forge"' |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected static function registerDatabaseCredentials(Cli $cli) |
35
|
|
|
{ |
36
|
|
|
return $cli->opt( |
37
|
|
|
'connection-username', |
38
|
|
|
'The username to use, defaults to DB_USERNAME and "forge"' |
39
|
|
|
)->opt( |
40
|
|
|
'connection-password', |
41
|
|
|
'The password to use, defaults to DB_PASSWORD and ""' |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected static function registerDatabasePostgreSqlOpts(Cli $cli) |
46
|
|
|
{ |
47
|
|
|
return $cli->opt( |
48
|
|
|
'connection-schema', |
49
|
|
|
'PostgreSQL only: The schema to use, defaults to DB_SCHEMA and "public"' |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected static function registerDatabaseMySqlOpts(Cli $cli) |
54
|
|
|
{ |
55
|
|
|
return $cli->opt( |
56
|
|
|
'connection-collation', |
57
|
|
|
'MySQL only: The collation to use, defaults to DB_COLLATION and "utf8_unicode_ci"' |
58
|
|
|
)->opt( |
59
|
|
|
'connection-strict', |
60
|
|
|
'MySQL only: Force strict mode, detaults to DB_STRICT and false', |
61
|
|
|
false, |
62
|
|
|
'boolean' |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param Cli $cli |
68
|
|
|
* @return Cli |
69
|
|
|
*/ |
70
|
|
|
public static function registerDatabaseOpts(Cli $cli) |
71
|
|
|
{ |
72
|
|
|
$cli = static::registerDatabaseDriver($cli); |
73
|
|
|
$cli = static::registerDatabaseConnection($cli); |
74
|
|
|
$cli = static::registerDatabaseCredentials($cli); |
75
|
|
|
$cli = static::registerDatabasePostgreSqlOpts($cli); |
76
|
|
|
$cli = static::registerDatabaseMySqlOpts($cli); |
77
|
|
|
|
78
|
|
|
return $cli; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|