lib/splash/cli/commands.rb in prometheus-splash-0.5.0 vs lib/splash/cli/commands.rb in prometheus-splash-0.5.2
- old
+ new
@@ -7,10 +7,11 @@
include Splash::Backends
include Splash::Exiter
include Splash::Transports
include Splash::Templates
include Splash::Loggers
+ include Splash::Commands
desc "execute NAME", "run for command/sequence or ack result"
long_desc <<-LONGDESC
execute command or sequence or ack result\n
with --no-trace prevent storing execution trace in configured backend (see config file)\n
@@ -19,14 +20,14 @@
with --no-callback, never execute callback (:on_failure, :on_success)\n
never follow sequences\n
with --hostname, execute on an other Splash daemon node
LONGDESC
option :trace, :type => :boolean, :default => true
- option :ack, :type => :boolean, negate: false
+ option :ack, :type => :boolean, negate: false, :aliases => "-a"
option :notify, :type => :boolean, :default => true
option :callback, :type => :boolean, :default => true
- option :hostname, :type => :string
+ option :hostname, :type => :string, :aliases => "-H"
def execute(name)
log = get_logger
log.level = :fatal if options[:quiet]
if is_root? then
if options[:hostname] then
@@ -58,11 +59,11 @@
end
log.receive "Command execute confirmation"
res[:more] = "Remote command : :execute_command Scheduled"
splash_exit res
else
- command = Splash::CommandWrapper::new(name)
+ command = CommandWrapper::new(name)
if options[:ack] then
splash_exit command.ack
end
acase = command.call_and_notify trace: options[:trace], notify: options[:notify], callback: options[:callback]
splash_exit acase
@@ -81,11 +82,11 @@
with --in TIMING, Schedule in specified timing, like 12s, 1m, 2h, 3m10s, 10d\n
--in and --at are imcompatibles.\n
WARNING : scheduling by CLI are not percisted, so use it only for specifics cases.\n
NOTES : Scheduling, force trace, notifying and callback.
LONGDESC
- option :hostname, :type => :string, :default => Socket.gethostname
+ option :hostname, :type => :string, :default => Socket.gethostname, :aliases => "-H"
option :at, :type => :string
option :in, :type => :string
def schedule(name)
log = get_logger
log.level = :fatal if options[:quiet]
@@ -119,11 +120,11 @@
desc "treeview", "Show commands sequence tree"
long_desc <<-LONGDESC
Show commands sequence tree\n
with --hostname, ask other Splash daemon via transport\n
LONGDESC
- option :hostname, :type => :string
+ option :hostname, :type => :string, :aliases => "-H"
def treeview(command)
depht = 0
log = get_logger
if options[:hostname] then
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
@@ -167,12 +168,12 @@
long_desc <<-LONGDESC
Show configured commands\n
with --detail, show command details\n
with --hostname, ask other Splash daemon via transport\n
LONGDESC
- option :detail, :type => :boolean
- option :hostname, :type => :string
+ option :detail, :type => :boolean, :aliases => "-D"
+ option :hostname, :type => :string, :aliases => "-H"
def list
log = get_logger
list = {}
if options[:hostname] then
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
@@ -216,11 +217,11 @@
desc "show COMMAND", "Show specific configured command COMMAND"
long_desc <<-LONGDESC
Show specific configured command COMMAND\n
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
LONGDESC
- option :hostname, :type => :string
+ option :hostname, :type => :string, :aliases => "-H"
def show(command)
log = get_logger
list = {}
if options[:hostname] then
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
@@ -262,11 +263,11 @@
desc "lastrun COMMAND", "Show last running result for specific configured command COMMAND"
long_desc <<-LONGDESC
Show last running result for specific configured command COMMAND\n
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
LONGDESC
- option :hostname, :type => :string
+ option :hostname, :type => :string, :aliases => "-H"
def lastrun(command)
log = get_logger
backend = get_backend :execution_trace
redis = (backend.class == Splash::Backends::Redis)? true : false
if not redis and options[:hostname] then
@@ -305,13 +306,13 @@
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)\n
with --all, get all execution report for all servers (only with Redis backend configured)\n
with --detail, get major informations of each reports\n
--all and --hostname are exclusives
LONGDESC
- option :pattern, :type => :string
- option :hostname, :type => :string
- option :all, :type => :boolean, :negate => false
- option :detail, :type => :boolean
+ option :pattern, :type => :string, :aliases => "-p"
+ option :hostname, :type => :string, :aliases => "-H"
+ option :all, :type => :boolean, :negate => false, :aliases => "-A"
+ option :detail, :type => :boolean, :aliases => "-D"
def getreportlist
log = get_logger
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
if options[:hostname] and options[:all] then
splash_exit case: :options_incompatibility, more: "--all, --hostname"