class Gzr::Commands::Plan::Import
Public Class Methods
new(plan_file, obj_type, obj_id, options)
click to toggle source
Calls superclass method
Gzr::Command::new
# File lib/gzr/commands/plan/import.rb, line 36 def initialize(plan_file, obj_type, obj_id, options) super() @plan_file = plan_file @obj_type = obj_type @obj_id = obj_id @options = options end
Public Instance Methods
execute(input: $stdin, output: $stdout)
click to toggle source
# File lib/gzr/commands/plan/import.rb, line 44 def execute(input: $stdin, output: $stdout) say_warning("options: #{@options.inspect}") if @options[:debug] with_session do @me ||= query_me("id") read_file(@plan_file) do |data| plan = nil case @obj_type when /dashboard/i plan = upsert_plan_for_dashboard(@obj_id,@me.id,data) when /look/i plan = upsert_plan_for_look(@obj_id,@me.id,data) else raise Gzr::CLI::Error, "Invalid type '#{obj_type}', valid types are look and dashboard" end output.puts "Imported plan #{plan.id}" unless @options[:plain] output.puts plan.id if @options[:plain] end end end