Sha256: e14473e1e5632a07ea725663329a080244822f1cfb64dca5037290ce6ef20ba4

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

#!/usr/bin/env ruby
require 'rbpw'
require 'thor'

module Rbpw
  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!}"
      File.write(PW_DATA, JSON.generate(new_pw(name, id, pw)))
    end

    desc "list", "show site_name"
    def list
        puts load_json&.keys
    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)
      File.write(PW_DATA, JSON.generate(load_json.delete(item)))
    end

    desc "copy [item] [id or pw]", "copy item"
    def copy(item, value)
      load_json.dig(item, value)
      Clipboard.copy(load_json.dig(item, value))
    end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbpw-0.0.2 lib/rbpw/cli.rb