lib/rbpw/cli.rb in rbpw-0.0.1 vs lib/rbpw/cli.rb in rbpw-0.0.2
- old
+ new
@@ -6,33 +6,36 @@
class CLI < Thor
desc "new [item]", "add new your id & password set with key item"
def new(name)
puts "What's your id?"
+ # Currently, it is assumed that the data is typed on the console, so it cuts line breaks.
id = "#{$stdin.gets.chomp!}"
puts "What's your pw? "
pw = "#{$stdin.gets.chomp!}"
- save_pw(new_pw(name, id, pw))
+ File.write(PW_DATA, JSON.generate(new_pw(name, id, pw)))
end
desc "list", "show site_name"
def list
- show_list
+ puts load_json&.keys
end
- desc "update [item]", "update items id or password"
- def update
- show_list
- end
+ # desc "update [item]", "update items id or password"
+ # def update(item, value)
+ # update_item(item, value)
+ # show_list
+ # end
desc "delete [item]", "delete item"
def delete(item)
- delete_item(item)
+ File.write(PW_DATA, JSON.generate(load_json.delete(item)))
end
desc "copy [item] [id or pw]", "copy item"
- def cp(item, value)
- clip_board_copy(item, value)
+ def copy(item, value)
+ load_json.dig(item, value)
+ Clipboard.copy(load_json.dig(item, value))
end
end
end
\ No newline at end of file