lib/rformat/application.rb in rformat-0.1.0 vs lib/rformat/application.rb in rformat-0.1.1
- old
+ new
@@ -1,6 +1,7 @@
require 'optparse'
+require 'pry'
require 'rformat'
require 'rformat/environment'
module RFormat
@@ -28,22 +29,22 @@
def run
parse_command
parse_options
if @command && @command !~ /^-/
- self.send(@command, @args)
+ @args.empty? ? self.send(@command) : self.send(@command, @args)
else
help
end
end
def help
@output.puts File.read File.join(RFormat::root_dir, 'HELP.txt')
end
- def list(args)
+ def list
@output.puts "Formatters:"
@output.puts @environment.formatters.keys.map { |f| " #{f}\n" }
end
def version
@@ -68,12 +69,16 @@
@output.puts "rspec now using format(s): #{config[:formats].values.join(', ')}"
end
end
def parse_command
- command = @args.first == 'list' ? @args.shift : @args.first
- command = command.to_sym if command.respond_to? :to_sym
- @command = command == :list ? :list : :write
+ command = :help if @args.empty?
+ if @args.first && @args.first == 'list'
+ command = :list
+ @args.shift
+ end
+ command = :write if command.nil?
+ @command = command
end
def parse_options
@options = {}
OptionParser.new do |opts|
\ No newline at end of file