Permalink
Browse files

itms: added --no-config, fixed load_config() bug

  • Loading branch information...
1 parent f09ff05 commit 39e2cfe15f1b83a45311cf454c89ddea0b967d06 sshaw committed Jul 30, 2012
Showing with 9 additions and 7 deletions.
  1. 0 .gitignore
  2. +2 −0 Changes
  3. +7 −7 bin/itms
View
0 .gitignore 100755 → 100644
No changes.
View
@@ -1,6 +1,8 @@
Version 0.0.2
--------------------
+* `itms` added --no-config option
* `itms` allow boolean options to be set to false via --no-XXXX, e.g., --no-print-stderr
* Bug fix: Status command ignored multiple status lines
* Bug fix: Lookup command failed to create tempdir
* Bug fix: `itms status` passed the wrong arguments to the underlying method
+* Bug fix: `itms` failed when the config file was empty
View
@@ -137,21 +137,21 @@ class Email
end
COMMANDS = ITunes::Store::Transporter.instance_methods(false).map(&:to_s)
-RC_FILE_NAME = ".itms"
+CONFIG_FILE_NAME = ".itms"
def home
ENV["HOME"] || ENV["USERPROFILE"]
end
# Should probably create a class for the options
def load_config(command)
- config = {}
- return config unless home
+ return {} unless home
- path = File.join(home, RC_FILE_NAME)
- return config unless File.file?(path)
+ path = File.join(home, CONFIG_FILE_NAME)
+ return {} unless File.file?(path)
config = YAML.load_file(path)
+ return {} unless config
# Get the global defaults. select() returns an aray on Ruby < 1.9
defaults = config.select { |k,v| !v.is_a?(Hash) }
@@ -202,7 +202,7 @@ command = ARGV.shift
abort("usage: itms command [options]") unless command
abort("invalid command '#{command}', valid commands are: #{COMMANDS.sort.join(', ')}") unless COMMANDS.include?(command)
-options = load_config(command)
+options = ARGV.delete("--no-config") ? {} : load_config(command)
while ARGV.any?
opt = ARGV.first.dup
@@ -214,7 +214,7 @@ while ARGV.any?
if val
val = val.to_i if val =~ /\A\d+\z/
else
- # Boolean option
+ # Boolean option
val = key.sub!(/\Ano_(?=\w)/, "") ? false : true
end

0 comments on commit 39e2cfe

Please sign in to comment.