From 97a82467ccfaef7c809b366dbc84ad42afd6f495 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 7 Sep 2016 00:01:08 +0200 Subject: [PATCH] add option to list all configured server connections --- src/shpub/Cli.php | 16 ++++++++++++++++ src/shpub/Command/Server.php | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/shpub/Command/Server.php diff --git a/src/shpub/Cli.php b/src/shpub/Cli.php index 32dcbe2..a57b287 100644 --- a/src/shpub/Cli.php +++ b/src/shpub/Cli.php @@ -32,6 +32,10 @@ class Cli $cmd = new Command_Like($this->cfg->host); $cmd->run($res->command->args['url']); break; + case 'server': + $cmd = new Command_Server($this->cfg); + $cmd->run($res->command->options['verbose']); + break; default: var_dump($this->cfg->host, $res); Log::err('FIXME'); @@ -142,6 +146,18 @@ class Cli ] ); + $cmd = $optParser->addCommand('server'); + $cmd->addOption( + 'verbose', + array( + 'short_name' => '-v', + 'long_name' => '--verbose', + 'description' => 'Show more server infos', + 'action' => 'StoreTrue', + 'default' => false, + ) + ); + //$cmd = $optParser->addCommand('post'); $cmd = $optParser->addCommand('reply'); $cmd->addArgument( diff --git a/src/shpub/Command/Server.php b/src/shpub/Command/Server.php new file mode 100644 index 0000000..59843d4 --- /dev/null +++ b/src/shpub/Command/Server.php @@ -0,0 +1,22 @@ +cfg = $cfg; + } + + public function run($verbose) + { + foreach ($this->cfg->hosts as $key => $host) { + echo $key . "\n"; + if ($verbose) { + echo ' URL: ' . $host->server . "\n"; + echo ' User: ' . $host->user . "\n"; + } + } + } +} +?> -- 2.30.2