Class: Textus::CLI::Verb::Mv

Inherits:
Textus::CLI::Verb show all
Defined in:
lib/textus/cli/verb/mv.rb

Instance Attribute Summary

Attributes inherited from Textus::CLI::Verb

#positional

Instance Method Summary collapse

Methods inherited from Textus::CLI::Verb

command_name, #context_for, descendants, #emit, inherited, #initialize, needs_store?, option, options, parent_group, #parse, #resolved_role, #session_for

Constructor Details

This class inherits a constructor from Textus::CLI::Verb

Instance Method Details

#call(store) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/textus/cli/verb/mv.rb', line 12

def call(store)
  if prefix
    from_p = positional.shift or raise UsageError.new("mv --prefix requires <from-prefix> <to-prefix>")
    to_p   = positional.shift or raise UsageError.new("mv --prefix requires <from-prefix> <to-prefix>")
    emit(session_for(store).key_mv_prefix(from_prefix: from_p, to_prefix: to_p,
                                          dry_run: dry_run || false).to_h)
  else
    old_key = positional.shift or raise UsageError.new("mv requires <old-key> <new-key>")
    new_key = positional.shift or raise UsageError.new("mv requires <old-key> <new-key>")
    emit(session_for(store).mv(old_key, new_key, dry_run: dry_run || false))
  end
end