Make 'server' and 'storage' optional for 'auto'
Resolves #35. Takes the value from the global config file as default argument. If it doesn't exist, but something in the config file exists, it takes that. If a command line argument is provided, it always takes precedence.
This commit is contained in:
@@ -37,8 +37,6 @@ class Auto implements Command {
|
|||||||
* @return \Generator
|
* @return \Generator
|
||||||
*/
|
*/
|
||||||
private function doExecute(Manager $args) {
|
private function doExecute(Manager $args) {
|
||||||
$server = $args->get("server");
|
|
||||||
$storage = $args->get("storage");
|
|
||||||
$configPath = $args->get("config");
|
$configPath = $args->get("config");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -55,6 +53,26 @@ class Auto implements Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($args->exists("server")) {
|
||||||
|
$config["server"] = $args->get("server");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($args->exists("storage")) {
|
||||||
|
$config["storage"] = $args->get("storage");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($config["server"])) {
|
||||||
|
$this->climate->error("Config file ({$configPath}) didn't have a 'server' set nor was it passed as command line argument.");
|
||||||
|
yield new CoroutineResult(self::EXIT_CONFIG_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($config["storage"])) {
|
||||||
|
$this->climate->error("Config file ({$configPath}) didn't have a 'storage' set nor was it passed as command line argument.");
|
||||||
|
yield new CoroutineResult(self::EXIT_CONFIG_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($config["email"])) {
|
if (!isset($config["email"])) {
|
||||||
$this->climate->error("Config file ({$configPath}) didn't have a 'email' set.");
|
$this->climate->error("Config file ({$configPath}) didn't have a 'email' set.");
|
||||||
yield new CoroutineResult(self::EXIT_CONFIG_ERROR);
|
yield new CoroutineResult(self::EXIT_CONFIG_ERROR);
|
||||||
@@ -72,9 +90,9 @@ class Auto implements Command {
|
|||||||
$GLOBALS["argv"][0],
|
$GLOBALS["argv"][0],
|
||||||
"setup",
|
"setup",
|
||||||
"--server",
|
"--server",
|
||||||
$server,
|
$config["server"],
|
||||||
"--storage",
|
"--storage",
|
||||||
$storage,
|
$config["storage"],
|
||||||
"--email",
|
"--email",
|
||||||
$config["email"],
|
$config["email"],
|
||||||
]));
|
]));
|
||||||
@@ -277,9 +295,15 @@ MESSAGE;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefinition() {
|
public static function getDefinition() {
|
||||||
|
$server = \Kelunik\AcmeClient\getArgumentDescription("server");
|
||||||
|
$storage = \Kelunik\AcmeClient\getArgumentDescription("storage");
|
||||||
|
|
||||||
|
$server["required"] = false;
|
||||||
|
$storage["required"] = false;
|
||||||
|
|
||||||
$args = [
|
$args = [
|
||||||
"server" => \Kelunik\AcmeClient\getArgumentDescription("server"),
|
"server" => $server,
|
||||||
"storage" => \Kelunik\AcmeClient\getArgumentDescription("storage"),
|
"storage" => $storage,
|
||||||
"config" => [
|
"config" => [
|
||||||
"prefix" => "c",
|
"prefix" => "c",
|
||||||
"longPrefix" => "config",
|
"longPrefix" => "config",
|
||||||
|
|||||||
Reference in New Issue
Block a user