class Gzr::Commands::Attribute::Cat
Public Class Methods
new(attr,options)
click to toggle source
Calls superclass method
Gzr::Command::new
# File lib/gzr/commands/attribute/cat.rb, line 34 def initialize(attr,options) super() @attr = attr @options = options end
Public Instance Methods
execute(input: $stdin, output: $stdout)
click to toggle source
# File lib/gzr/commands/attribute/cat.rb, line 40 def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do f = @options[:fields] id = @attr if /^\d+$/.match @attr attr = nil if id attr = query_user_attribute(id,f) else attr = get_attribute_by_name(@attr,f) end raise(Gzr::CLI::Error, "Attribute #{@attr} does not exist") unless attr write_file(@options[:dir] ? "Attribute_#{attr.id}_#{attr.name}.json" : nil, @options[:dir],nil, output) do |f| f.puts JSON.pretty_generate(attr.to_attrs) end end end