Sha256: f34aa695797effb4a6dbc8dc8d33a66f83b00193f1a05fc8f1d8e924760f205a

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

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

module Rbpw
  class CLI < Thor
    desc "new [item, username(opt), password(opt)]", "add new item"
    def new(key, username = nil , password = nil )
      # Currently, it is assumed that the data is typed on the console, so it cuts line breaks.
      if username.nil?
        puts "What's your username?"
        username = "#{$stdin.gets.chomp!}"
      end
      if password.nil?
      puts "What's your password? "
      password = "#{$stdin.gets.chomp!}"
      end
      save_to_db(set_data(key, username, password))
    end

    desc "show [item]", "show item data set"
    def show(key)
      data = read_from_db(key)
      puts "username: #{data.get_username}"
      puts "password: #{data.get_password}"
    end

    desc "update [item]", "update item password"
    def update(key)
      # 例外をメソッドに書く
      data = read_from_db(key)
      puts "input change password"
      data.set_password("#{$stdin.gets.chomp!}")
      save_to_db(data)
    end

    desc "delete [item]", "delete item"
    def delete(key)
      delete_item(key)
      puts "delete item #{key}"
    end

    desc "copy [item]", "copy password in your Clipboard"
    def copy(key)
      clip_board_copy(key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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