lib/invoker/cli.rb in invoker-1.4.1 vs lib/invoker/cli.rb in invoker-1.5.1
- old
+ new
@@ -11,12 +11,15 @@
end
super(*args)
end
desc "setup", "Run Invoker setup"
+ option :tld,
+ type: :string,
+ banner: 'Configure invoker to use a different top level domain'
def setup
- Invoker::Power::Setup.install
+ Invoker::Power::Setup.install(get_tld(options))
end
desc "version", "Print Invoker version"
def version
Invoker::Logger.puts Invoker::VERSION
@@ -37,11 +40,11 @@
def start(file = nil)
Invoker.setup_config_location
port = options[:port] || 9000
Invoker.daemonize = options[:daemon]
Invoker.load_invoker_config(file, port)
- warn_about_terminal_notifier
+ warn_about_notification
warn_about_old_configuration
pinger = Invoker::CLI::Pinger.new(unix_socket)
abort("Invoker is already running".color(:red)) if pinger.invoker_running?
Invoker.commander.start_manager
end
@@ -49,13 +52,13 @@
desc "add process", "Add a program to Invoker server"
def add(name)
unix_socket.send_command('add', process_name: name)
end
- desc "add_http process_name port", "Add an external http process to Invoker DNS server"
- def add_http(name, port)
- unix_socket.send_command('add_http', process_name: name, port: port)
+ desc "add_http process_name port [IP]", "Add an external http process to Invoker DNS server"
+ def add_http(name, port, ip = nil)
+ unix_socket.send_command('add_http', process_name: name, port: port, ip: ip)
end
desc "tail process1 process2", "Tail a particular process"
def tail(*names)
tailer = Invoker::CLI::Tail.new(names)
@@ -103,15 +106,38 @@
def self.valid_tasks
tasks.keys + ["help"]
end
+ def get_tld(options)
+ if options[:tld] && !options[:tld].empty?
+ options[:tld]
+ else
+ 'dev'
+ end
+ end
+
def unix_socket
Invoker::IPC::UnixClient.new
end
+ def warn_about_notification
+ if Invoker.darwin?
+ warn_about_terminal_notifier
+ else
+ warn_about_libnotify
+ end
+ end
+
+ def warn_about_libnotify
+ require "libnotify"
+ rescue LoadError
+ Invoker::Logger.puts "You can install libnotify gem for Invoker notifications "\
+ "via system tray".color(:red)
+ end
+
def warn_about_terminal_notifier
- if RUBY_PLATFORM.downcase.include?("darwin")
+ if Invoker.darwin?
command_path = `which terminal-notifier`
if !command_path || command_path.empty?
Invoker::Logger.puts "You can enable OSX notification for processes "\
"by installing terminal-notifier gem".color(:red)
end