5 * Inspect the list of saved connections/servers.
7 * @author Christian Weiske <cweiske@cweiske.de>
8 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
9 * @link http://cweiske.de/shpub.htm
13 public function __construct(Config $cfg)
18 public static function opts(\Console_CommandLine $optParser)
20 $cmd = $optParser->addCommand('server');
21 $cmd->description = 'List all connections';
26 'long_name' => '--verbose',
27 'description' => 'Show more server infos',
28 'action' => 'StoreTrue',
37 'description' => 'Connection name',
42 public function run($server, $verbose)
44 if ($server === null) {
45 $this->showConnections($verbose);
47 $this->showConnectionDetails($server, $verbose);
52 * Show a list of all connections
54 * @param bool $verbose Show some details
58 protected function showConnections($verbose)
60 foreach ($this->cfg->hosts as $key => $host) {
63 Log::msg(' URL: ' . $host->server);
64 Log::msg(' User: ' . $host->user);
70 * Show detailled information for single connection
72 * @param string $server Connection name
73 * @param bool $verbose Show the token
77 protected function showConnectionDetails($server, $verbose)
79 if (!isset($this->cfg->hosts[$server])) {
80 Log::err('Connection does not exist: ' . $server);
84 $host = $this->cfg->hosts[$server];
86 Log::msg(' URL: ' . $host->server);
87 Log::msg(' User: ' . $host->user);
89 Log::msg(' Token: ' . $host->token);
92 Log::msg(' Endpoints:');
93 $host->loadEndpoints();
94 foreach ($host->endpoints as $key => $value) {
95 Log::msg(' ' . str_pad($key . ': ', 15, ' ') . $value);