Class: Pwl::Commands::Add
Instance Method Summary collapse
Methods inherited from Base
default_locker_file, exit_codes_help
Instance Method Details
#call(args, options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pwl/commands/add.rb', line 4 def call(args, ) exit_with(:name_blank, .verbose) if 0 == args.size || args[0].blank? # Ask for the master password _before_ it may be necessary to ask for the value in a terminal begin locker = open_locker() rescue Pwl::Dialog::Cancelled exit_with(:aborted, .verbose) end value = args[1] if !value exit_with(:value_blank, .verbose) unless STDIN.tty? || .gui begin value = get_text("Enter value for name '#{args[0]}':", .gui) rescue Pwl::Dialog::Cancelled exit_with(:aborted, .verbose) end # still blank, even after asking for it? if value.blank? exit_with(:value_blank, true) end end locker.add(args[0], value) msg "Successfully stored new value under #{args[0]}." if .verbose end |