imapget 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +1 -1
  2. data/bin/imapget +27 -23
  3. data/lib/imapget/version.rb +1 -1
  4. metadata +2 -2
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to imapget version 0.0.3
5
+ This documentation refers to imapget version 0.0.4
6
6
 
7
7
 
8
8
  == DESCRIPTION
data/bin/imapget CHANGED
@@ -36,8 +36,7 @@ $: << File.join(File.dirname(__FILE__), '..', 'lib')
36
36
 
37
37
  require 'imapget'
38
38
 
39
- USAGE = "Usage: #{$0} [-h|--help] [options] <profile>"
40
- abort USAGE if ARGV.empty?
39
+ USAGE = "Usage: #{$0} [-h|--help] [options] [profile]..."
41
40
 
42
41
  options = {
43
42
  :config => 'config.yaml',
@@ -52,8 +51,6 @@ OptionParser.new { |opts|
52
51
  opts.separator 'Options:'
53
52
 
54
53
  opts.on('-c', '--config YAML', "Config file [Default: #{options[:config]}#{' (currently not present)' unless File.readable?(options[:config])}]") { |f|
55
- abort "Can't find config file: #{f}." unless File.readable?(f)
56
-
57
54
  options[:config] = f
58
55
  }
59
56
 
@@ -81,29 +78,36 @@ OptionParser.new { |opts|
81
78
  }
82
79
  }.parse!
83
80
 
84
- profile = ARGV.shift
85
- abort "Profile missing\n#{USAGE}" unless profile
81
+ abort "Config file not found: #{options[:config]}\n#{USAGE}" unless File.readable?(options[:config])
86
82
 
87
- global_config = YAML.load_file(options[:config])
83
+ global_config = YAML.load_file(options[:config])
84
+ default_config = global_config.reject { |k, _| k.is_a?(String) }
88
85
 
89
- config = global_config[profile]
90
- abort "Profile not found: #{profile}" unless config
86
+ profiles = ARGV.empty? ? global_config.keys.select { |k| k.is_a?(String) }.sort : ARGV
91
87
 
92
- global_config.delete_if { |k, _| k.is_a?(String) }
93
- config.update(global_config) { |key, old, new| old }
88
+ profiles.each { |profile|
89
+ unless config = global_config[profile]
90
+ warn "Profile not found: #{profile}"
91
+ next
92
+ end
94
93
 
95
- host = config[:host]
96
- abort "No host for profile #{profile}" unless host
94
+ config.update(default_config) { |key, old, new| old }
97
95
 
98
- config[:user] ||= ask("User for #{host}: ")
99
- config[:password] ||= ask("Password for #{config[:user]}@#{host}: ") { |q| q.echo = false }
96
+ unless host = config[:host]
97
+ warn "No host for profile #{profile}"
98
+ next
99
+ end
100
100
 
101
- imapget = IMAPGet.new(config)
101
+ config[:user] ||= ask("User for #{profile} on #{host}: ")
102
+ config[:password] ||= ask("Password for #{config[:user]}@#{host}: ") { |q| q.echo = false }
102
103
 
103
- if options[:check]
104
- imapget.each { |mailbox|
105
- puts mailbox.name
106
- }
107
- else
108
- imapget.get(options[:directory] || File.join(config[:base_dir] || '.', profile))
109
- end
104
+ imapget = IMAPGet.new(config)
105
+
106
+ if options[:check]
107
+ imapget.each { |mailbox|
108
+ puts mailbox.name
109
+ }
110
+ else
111
+ imapget.get(options[:directory] || File.join(config[:base_dir] || '.', profile))
112
+ end
113
+ }
@@ -4,7 +4,7 @@ class IMAPGet
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 0
7
- TINY = 3
7
+ TINY = 4
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imapget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 +02:00
12
+ date: 2009-05-25 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency