lib/cloudstack-cli/commands/resource_limit.rb in cloudstack-cli-1.4.1 vs lib/cloudstack-cli/commands/resource_limit.rb in cloudstack-cli-1.4.2
- old
+ new
@@ -16,10 +16,12 @@
desc "list", "list resource limits"
option :account
option :project
option :type, desc: "specify type, see types for a list of types"
+ option :format, default: "table",
+ enum: %w(table json yaml)
def list
resolve_account
resolve_project
limits = client.list_resource_limits(options)
table = []
@@ -32,11 +34,19 @@
limit['resourcetype'],
RESOURCE_TYPES[limit['resourcetype']][:name],
resource_to_s(limit, 'max')
]
end
- table = table.insert(0, header)
- print_table table
+
+ case options[:format].to_sym
+ when :yaml
+ puts({resource_limits: limits}.to_yaml)
+ when :json
+ puts JSON.pretty_generate(resource_limits: limits)
+ else
+ table = table.insert(0, header)
+ print_table table
+ end
end
desc "refresh", "refresh resource counts"
option :domain, desc: "refresh resource for a specified domain"
option :account, desc: "refresh resource for a specified account"