Module: OsCtl::Cli::Assets

Included in:
Container, Group, IdRange, Pool, Repository, Self, User
Defined in:
lib/osctl/cli/assets.rb

Instance Method Summary collapse

Instance Method Details



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/osctl/cli/assets.rb', line 5

def print_assets(cmd, **cmd_opts)
  data = osctld_call(cmd, **cmd_opts)
  cols = [
    :type,
    :path,
    :state,
    {
      name: :purpose,
      label: 'PURPOSE',
      display: ->(_, asset) { asset[:opts][:desc] }
    }
  ]

  if opts[:verbose]
    cols << {
      name: :errors,
      label: 'ERRORS',
      display: ->(_, asset) { asset[:errors].join('; ') }
    }
  end

  format_output(data, cols:, layout: opts[:verbose] ? :rows : :columns)
end