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'
22 . "\nPass the connection name to see all details:"
23 . " URL, user, endpoint URLs";
28 'long_name' => '--verbose',
29 'description' => 'Show more server infos',
30 'action' => 'StoreTrue',
39 'description' => 'Connection name',
44 public function run($server, $verbose)
46 if ($server === null) {
47 $this->showConnections($verbose);
49 $this->showConnectionDetails($server, $verbose);
54 * Show a list of all connections
56 * @param bool $verbose Show some details
60 protected function showConnections($verbose)
62 foreach ($this->cfg->hosts as $key => $host) {
65 Log::msg(' URL: ' . $host->server);
66 Log::msg(' User: ' . $host->user);
72 * Show detailled information for single connection
74 * @param string $server Connection name
75 * @param bool $verbose Show the token
79 protected function showConnectionDetails($server, $verbose)
81 if (!isset($this->cfg->hosts[$server])) {
82 Log::err('Connection does not exist: ' . $server);
86 $host = $this->cfg->hosts[$server];
88 Log::msg(' URL: ' . $host->server);
89 Log::msg(' User: ' . $host->user);
91 Log::msg(' Token: ' . $host->token);
94 Log::msg(' Endpoints:');
95 $host->loadEndpoints();
96 foreach ($host->endpoints as $key => $value) {
97 Log::msg(' ' . str_pad($key . ': ', 15, ' ') . $value);