lib/spanx/cli.rb in spanx-0.1.1 vs lib/spanx/cli.rb in spanx-0.3.0
- old
+ new
@@ -18,13 +18,18 @@
end
private
def validate!
- error_exit_with_msg("No command given") if args.empty?
+ error_exit_with_msg('No command given') if args.empty?
@command = args.first
- error_exit_with_msg("No command found matching #{@command}") unless Spanx::CLI.subclasses.include?(@command)
+ if !@command.eql?('-h') && !@command.eql?('--help')
+ error_exit_with_msg("No command found matching #{@command}") unless Spanx::CLI.subclasses.include?(@command)
+ else
+ help_exit
+ end
+
end
def generate_config(argv)
parse_options argv
config.merge! Spanx::Config.new(config[:config_file])
@@ -33,15 +38,15 @@
if config[:debug]
STDOUT.sync = true
end
Spanx::Logger.enable if config[:debug]
+ rescue OptionParser::InvalidOption => e
+ error_exit_with_msg "Whoops, #{e.message}"
end
end
end
-require 'spanx/cli/watch'
-require 'spanx/cli/analyze'
-require 'spanx/cli/disable'
-require 'spanx/cli/enable'
-require 'spanx/cli/flush'
+Dir.glob("#{File.expand_path('../cli', __FILE__)}/*.rb").each do |file|
+ require file
+end