diff --git a/bin/mpw-add b/bin/mpw-add index a0e450f..5322cc1 100644 --- a/bin/mpw-add +++ b/bin/mpw-add @@ -24,7 +24,8 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} +options = {} +options[:sync] = true OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw add [options]" @@ -38,6 +39,10 @@ OptionParser.new do |opts| exit 0 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 options[:password] = true end diff --git a/bin/mpw-config b/bin/mpw-config index 133f3c4..120da5b 100644 --- a/bin/mpw-config +++ b/bin/mpw-config @@ -65,9 +65,9 @@ config = MPW::Config.new(options[:config]) cli = MPW::Cli.new(config, nil) if not options[:init].nil? + cli.setup(values) cli.load_config cli.get_wallet - cli.setup(values) cli.setup_gpg_key(options[:init]) cli.setup_wallet_config else diff --git a/bin/mpw-copy b/bin/mpw-copy index aa42c9a..0a14ed7 100644 --- a/bin/mpw-copy +++ b/bin/mpw-copy @@ -24,7 +24,8 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} +options = {} +options[:sync] = true options[:clipboard] = true values = {} diff --git a/bin/mpw-delete b/bin/mpw-delete index d0e76d5..2d79e6a 100644 --- a/bin/mpw-delete +++ b/bin/mpw-delete @@ -24,8 +24,9 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} -values = {} +options = {} +options[:sync] = true +values = {} OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw delete [options]" @@ -43,6 +44,10 @@ OptionParser.new do |opts| exit 0 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| values[:pattern] = pattern end diff --git a/bin/mpw-export b/bin/mpw-export index f5a2145..f891873 100644 --- a/bin/mpw-export +++ b/bin/mpw-export @@ -24,8 +24,9 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} -values = {} +options = {} +options[:sync] = true +values = {} OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]" @@ -47,6 +48,10 @@ OptionParser.new do |opts| exit 0 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| values[:pattern] = pattern end diff --git a/bin/mpw-import b/bin/mpw-import index ad52f57..c740252 100644 --- a/bin/mpw-import +++ b/bin/mpw-import @@ -24,7 +24,8 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} +options = {} +options[:sync] = true OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw import [options]" @@ -42,6 +43,10 @@ OptionParser.new do |opts| exit 0 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| options[:wallet] = wallet end @@ -50,10 +55,6 @@ end.parse! config = MPW::Config.new(options[:config]) cli = MPW::Cli.new(config, options[:sync]) -opts = { search: options[:pattern], - group: options[:group], - } - cli.load_config cli.get_wallet(options[:wallet]) cli.decrypt diff --git a/bin/mpw-list b/bin/mpw-list index 839e00f..9d18b0d 100644 --- a/bin/mpw-list +++ b/bin/mpw-list @@ -24,8 +24,9 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} -values = {} +options = {} +options[:sync] = true +values = {} OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw list [options]" @@ -47,6 +48,10 @@ OptionParser.new do |opts| values[:pattern] = pattern 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| options[:wallet] = wallet end diff --git a/bin/mpw-update b/bin/mpw-update index 598920b..301b876 100644 --- a/bin/mpw-update +++ b/bin/mpw-update @@ -24,8 +24,9 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} -values = {} +options = {} +options[:sync] = true +values = {} OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw update [options]" @@ -43,6 +44,10 @@ OptionParser.new do |opts| exit 0 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| values[:pattern] = pattern end diff --git a/bin/mpw-wallet b/bin/mpw-wallet index 8e33426..b81e6b2 100644 --- a/bin/mpw-wallet +++ b/bin/mpw-wallet @@ -24,8 +24,9 @@ require 'mpw/cli' # Options # --------------------------------------------------------- # -options = {} -values = {} +options = {} +options[:sync] = {} +values = {} OptionParser.new do |opts| opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]" @@ -47,6 +48,10 @@ OptionParser.new do |opts| options[:list] = true end + opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do + options[:sync] = false + end + opts.on('--password', I18n.t('option.password')) do values[:password] = true end diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index 884f752..0215a70 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -289,10 +289,10 @@ class MPW case @config['protocol'] when 'sftp', 'scp', 'ssh' require "mpw/sync/ssh" - sync = SyncSSH.new(@config['sync']) + sync = SyncSSH.new(@config) when 'ftp' require 'mpw/sync/ftp' - sync = SyncFTP.new(@config['sync']) + sync = SyncFTP.new(@config) else raise I18n.t('error.sync.unknown_type') end