add option to list all configured server connections
authorChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 22:01:08 +0000 (00:01 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 22:01:08 +0000 (00:01 +0200)
src/shpub/Cli.php
src/shpub/Command/Server.php [new file with mode: 0644]

index 32dcbe2d929e5c0332571ebc3d372fa9924a3f38..a57b287fda084518f5f47f2066105507be58a45b 100644 (file)
@@ -32,6 +32,10 @@ class Cli
                 $cmd = new Command_Like($this->cfg->host);
                 $cmd->run($res->command->args['url']);
                 break;
                 $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');
             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(
         //$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 (file)
index 0000000..59843d4
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+namespace shpub;
+
+class Command_Server
+{
+    public function __construct(Config $cfg)
+    {
+        $this->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";
+            }
+        }
+    }
+}
+?>