lib/fix/command.rb in fix-command-0.2.0 vs lib/fix/command.rb in fix-command-0.3.0

- old
+ new

@@ -5,27 +5,37 @@ # Namespace for the Fix framework. # # @api public # # @example Let's test a duck's spec! -# Fix::Command.run('duck_fix.rb', '-w') +# Fix::Command.run('duck_fix.rb', '--warnings') # module Fix + # Fix reads command line configuration options from files in two different + # locations: + # + # Local: "./.fix" (i.e. in the project's root directory) + # Global: "~/.fix" (i.e. in the user's home directory) + # + # Options declared in the local file override those in the global file, while + # those declared in command-line will override any ".fix" file. + COMMAND_LINE_OPTIONS_FILE = '.fix' + # Open the command class. # # @api public # # @example Let's test a duck's spec! - # Command.run('duck_fix.rb', '-w') + # Command.run('duck_fix.rb', '--warnings') # class Command # Handle the parameters passed to fix command from the console. # # @api public # # @example Let's test a duck's spec! - # run('duck_fix.rb', '-w') + # run('duck_fix.rb', '--warnings') # # @param args [Array] A list of files and options. # # @raise [SystemExit] The result of the tests. def self.run(*args) @@ -41,11 +51,11 @@ str += ' --debug' if $DEBUG str += ' --warnings' if $VERBOSE str += ' --prefix' if config.fetch(:prefix) str += ' --suffix' if config.fetch(:suffix) - puts str + ' ' + file_paths.to_a.join(' ') + "\e[22m" + puts file_paths.to_a.join(' ') + ' ' + str + "\e[22m" status = true file_paths.each do |file_path| begin @@ -107,10 +117,16 @@ exit end end + %w(~ .).each do |c| + config_path = File.join(File.expand_path(c), COMMAND_LINE_OPTIONS_FILE) + opt_parser.load(config_path) + end + opt_parser.parse!(args) + options end # @private def self.fetch_file_paths(file_prefix, file_suffix, *args)