Class: ZonePrint

Inherits:
Command show all
Defined in:
lib/zone.rb

Instance Attribute Summary

Attributes inherited from Command

#desc, #name

Instance Method Summary collapse

Methods inherited from Command

#add_arg, #add_cmd, #add_flow, #add_flow_from_usage, #add_input, #add_option, #command_name?, #create_args, #create_flows, #get_args_used, #init, #initialize, #run, #show_help, #show_help_option

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#add_options ⇒ Object



38
39
40
41
# File 'lib/zone.rb', line 38

def add_options 
  add_option({ short_name: 'j', long_name: 'json', method: :set_format, takes_value: false})
  # add_option({ short_name: 'f', long_name: 'force-online', method: :force_online, takes_value: false})
end

#execute(args, rest) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/zone.rb', line 47

def execute(args, rest)
  struct = @input["struct"]
  level = @input["level"]
  sep_char = @input["sep_char"]
  if @format == :json
    puts JSON.pretty_generate(struct)
  else
    StructurePrint.new(sep_char).structure_print(struct, level)
  end
end

#set_format ⇒ Object



43
44
45
# File 'lib/zone.rb', line 43

def set_format
  @format = :json
end