lib/kontena/cli/master/current_command.rb in kontena-cli-0.15.5 vs lib/kontena/cli/master/current_command.rb in kontena-cli-0.16.0.pre1
- old
+ new
@@ -1,15 +1,23 @@
+require 'uri'
+
module Kontena::Cli::Master
- class CurrentCommand < Clamp::Command
+ class CurrentCommand < Kontena::Command
include Kontena::Cli::Common
option ["--name"], :flag, "Show name only", default: false
+ option ["--address"], :flag, "Show IP address or FQDN only", default: false
+ option ["--url"], :flag, "Show URL only", default: false
def execute
- master = current_master
+ master = require_current_master
if name?
puts master['name']
+ elsif address?
+ puts URI.parse(master['url']).host
+ elsif url?
+ puts master['url']
else
puts "#{master['name']} #{master['url']}"
end
end
end