1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-03-19 12:59:30 +00:00

enable sync

This commit is contained in:
Adrien Waksberg 2016-10-23 22:39:22 +02:00
parent 90e8b658bf
commit 5bcf26d251
10 changed files with 52 additions and 20 deletions

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw add [options]" opts.banner = "#{I18n.t('option.usage')}: mpw add [options]"
@ -38,6 +39,10 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-r', '--random', I18n.t('option.random_password')) do opts.on('-r', '--random', I18n.t('option.random_password')) do
options[:password] = true options[:password] = true
end end

View file

@ -65,9 +65,9 @@ config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, nil) cli = MPW::Cli.new(config, nil)
if not options[:init].nil? if not options[:init].nil?
cli.setup(values)
cli.load_config cli.load_config
cli.get_wallet cli.get_wallet
cli.setup(values)
cli.setup_gpg_key(options[:init]) cli.setup_gpg_key(options[:init])
cli.setup_wallet_config cli.setup_wallet_config
else else

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
options[:clipboard] = true options[:clipboard] = true
values = {} values = {}

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
@ -43,6 +44,10 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
values[:pattern] = pattern values[:pattern] = pattern
end end

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
@ -47,6 +48,10 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
values[:pattern] = pattern values[:pattern] = pattern
end end

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw import [options]" opts.banner = "#{I18n.t('option.usage')}: mpw import [options]"
@ -42,6 +43,10 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet options[:wallet] = wallet
end end
@ -50,10 +55,6 @@ end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config, options[:sync])
opts = { search: options[:pattern],
group: options[:group],
}
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])
cli.decrypt cli.decrypt

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
@ -47,6 +48,10 @@ OptionParser.new do |opts|
values[:pattern] = pattern values[:pattern] = pattern
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet options[:wallet] = wallet
end end

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
@ -43,6 +44,10 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
values[:pattern] = pattern values[:pattern] = pattern
end end

View file

@ -25,6 +25,7 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = {}
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
@ -47,6 +48,10 @@ OptionParser.new do |opts|
options[:list] = true options[:list] = true
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('--password', I18n.t('option.password')) do opts.on('--password', I18n.t('option.password')) do
values[:password] = true values[:password] = true
end end

View file

@ -289,10 +289,10 @@ class MPW
case @config['protocol'] case @config['protocol']
when 'sftp', 'scp', 'ssh' when 'sftp', 'scp', 'ssh'
require "mpw/sync/ssh" require "mpw/sync/ssh"
sync = SyncSSH.new(@config['sync']) sync = SyncSSH.new(@config)
when 'ftp' when 'ftp'
require 'mpw/sync/ftp' require 'mpw/sync/ftp'
sync = SyncFTP.new(@config['sync']) sync = SyncFTP.new(@config)
else else
raise I18n.t('error.sync.unknown_type') raise I18n.t('error.sync.unknown_type')
end end