Class: OsCtl::Cli::History
- Defined in:
- lib/osctl/cli/history.rb
Instance Method Summary collapse
Methods inherited from Command
#cli_opt, #format_output, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, run
Instance Method Details
#list ⇒ Object
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 40 |
# File 'lib/osctl/cli/history.rb', line 7 def list cols = [ { name: :time, label: 'TIME', display: proc do |t| Time.at(t).strftime('%Y-%m-%d %H:%M:%S') end }, :pool, { name: :cmd, label: 'COMMAND', display: proc 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 OsCtl::Lib::Cli::OutputFormatter.print(data, cols:, layout: :columns) end end |