Class: OsCtl::Cli::History
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
#cli_opt, #format_output, #initialize, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, #require_args!, run
Methods included from Utils::Humanize
#break_interval, #format_long_duration, #format_percent, #format_short_duration, #humanize_data, #humanize_time_ns, #parse_data
Constructor Details
This class inherits a constructor from OsCtl::Cli::Command
Instance Method Details
#list ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/osctl/cli/history.rb', line 6 def list cols = [ { name: :time, label: 'TIME', display: Proc.new do |t| Time.at(t).strftime('%Y-%m-%d %H:%M:%S') end, }, :pool, { name: :cmd, label: 'COMMAND', display: Proc.new do |cmd, event| if event[:opts] && event[:opts][:cli] event[:opts][:cli] else "#{cmd} #{event[:opts]}" end end, }, ] cmd_opts = {} cmd_opts[:pools] = args if args.any? data = osctld_call(:history_list, cmd_opts) if gopts[:json] data.each { puts data.to_json } else OutputFormatter.print(data, cols, layout: :columns) end end |