mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-22 02:40:04 +00:00
add class cli in module mpw
This commit is contained in:
parent
812a02d60e
commit
ad1713edcb
2 changed files with 5 additions and 3 deletions
2
bin/mpw
2
bin/mpw
|
@ -124,7 +124,7 @@ end.parse!
|
||||||
config = MPW::Config.new(options[:config])
|
config = MPW::Config.new(options[:config])
|
||||||
check_error = config.checkconfig
|
check_error = config.checkconfig
|
||||||
|
|
||||||
cli = Cli.new(config)
|
cli = MPW::Cli.new(config)
|
||||||
|
|
||||||
# Setup a new config
|
# Setup a new config
|
||||||
if not check_error or not options[:setup].nil?
|
if not check_error or not options[:setup].nil?
|
||||||
|
|
|
@ -11,6 +11,7 @@ require 'highline/import'
|
||||||
require "#{APP_ROOT}/../lib/mpw/item.rb"
|
require "#{APP_ROOT}/../lib/mpw/item.rb"
|
||||||
require "#{APP_ROOT}/../lib/mpw/mpw.rb"
|
require "#{APP_ROOT}/../lib/mpw/mpw.rb"
|
||||||
|
|
||||||
|
module MPW
|
||||||
class Cli
|
class Cli
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
|
@ -88,7 +89,7 @@ class Cli
|
||||||
def decrypt
|
def decrypt
|
||||||
if not defined?(@mpw)
|
if not defined?(@mpw)
|
||||||
@password = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
|
@password = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
|
||||||
@mpw = MPW::MPW.new(@config.key, @wallet_file, @password)
|
@mpw = MPW.new(@config.key, @wallet_file, @password)
|
||||||
end
|
end
|
||||||
|
|
||||||
@mpw.read_data
|
@mpw.read_data
|
||||||
|
@ -208,7 +209,7 @@ class Cli
|
||||||
options[:port] = ask(I18n.t('form.add.port')).to_s
|
options[:port] = ask(I18n.t('form.add.port')).to_s
|
||||||
options[:comment] = ask(I18n.t('form.add.comment')).to_s
|
options[:comment] = ask(I18n.t('form.add.comment')).to_s
|
||||||
|
|
||||||
item = MPW::Item.new(options)
|
item = Item.new(options)
|
||||||
|
|
||||||
@mpw.add(item)
|
@mpw.add(item)
|
||||||
@mpw.set_password(item.id, password)
|
@mpw.set_password(item.id, password)
|
||||||
|
@ -299,3 +300,4 @@ class Cli
|
||||||
puts "#{I18n.t('display.error')} #18: #{e}".red
|
puts "#{I18n.t('display.error')} #18: #{e}".red
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue