Class: S7n::S7nCli::EntryDeleteCommand

Inherits:
Command
  • Object
show all
Includes:
EntryCommandUtils
Defined in:
lib/s7n/s7ncli/entry_command.rb

Overview

機密情報を削除するコマンドを表現する。

Constant Summary

Constants included from EntryCommandUtils

S7n::S7nCli::EntryCommandUtils::EDITING_USAGE

Instance Attribute Summary

Attributes inherited from Command

#config, #options, #world

Instance Method Summary collapse

Methods included from EntryCommandUtils

#apply_entry_changes, #command_loop, #dispatch_command, #display_entry, #input_attribute_name, #input_attribute_type, #input_secret, #input_tags, #input_value

Methods inherited from Command

#aliases, create_instance, #description, #help, #initialize, #name, #option_parser, split_name_and_argv, #usage

Constructor Details

This class inherits a constructor from S7n::S7nCli::Command

Instance Method Details

#run(argv) ⇒ Object

コマンドを実行する。



702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'lib/s7n/s7ncli/entry_command.rb', line 702

def run(argv)
  if argv.length > 0
    id = argv.shift.to_i
  end
  if id.nil?
    puts(_("Too few arguments."))
    help
    return true
  end
  entry = world.entry_collection.find(id)
  if entry.nil?
    raise NoSuchEntry.new("id" => id)
  end
  display_entry(entry)
  puts("-----")
  if S7nCli.input_boolean(_("Delete? (no): "))
    # TODO: undo スタックに操作を追加。
    world.entry_collection.delete_entries(entry)
    puts(_("Deleted: %d") % entry.id)
  else
    canceled
  end
  return true
end