class Gzr::Commands::Look::Mv
Public Class Methods
new(look_id, target_space_id, options)
click to toggle source
Calls superclass method
Gzr::Command::new
# File lib/gzr/commands/look/mv.rb, line 33 def initialize(look_id, target_space_id, options) super() @look_id = look_id @target_space_id = target_space_id @options = options end
Public Instance Methods
execute(input: $stdin, output: $stdout)
click to toggle source
# File lib/gzr/commands/look/mv.rb, line 40 def execute(input: $stdin, output: $stdout) say_warning("options: #{@options.inspect}", output: output) if @options[:debug] with_session do look = query_look(@look_id) raise Gzr::CLI::Error, "Look with id #{@look_id} does not exist" unless look matching_title = search_looks_by_title(look[:title],@target_space_id) if matching_title.empty? || matching_title.first[:deleted] matching_title = false end if matching_title raise Gzr::CLI::Error, "Look #{look[:title]} already exists in space #{@target_space_id}\nUse --force if you want to overwrite it" unless @options[:force] say_ok "Deleting existing look #{matching_title.first[:id]} #{matching_title.first[:title]} in space #{@target_space_id}", output: output update_look(matching_title.first[:id],{:deleted=>true}) end update_look(look[:id],{:space_id=>@target_space_id}) output.puts "Moved look #{look[:id]} to space #{@target_space_id}" unless @options[:plain] end end