class Rbish::CLI
Public Instance Methods
run(argv=ARGV)
click to toggle source
# File lib/rbish/cli.rb, line 36 def run(argv=ARGV) parse_options(argv) version_check parse_cli_arguments Config.merge!(config) cmd = Command.new(@target, Config) cmd.run rescue OptionError => e Rbish.error("#{e.class}: #{e.message}") exit 1 rescue => e Rbish.error("#{e.class}: #{e.message}") exit 3 end
version_check()
click to toggle source
# File lib/rbish/cli.rb, line 29 def version_check if config[:version] puts "rbish #{Rbish::VERSION}" exit 0 end end
Private Instance Methods
parse_cli_arguments()
click to toggle source
# File lib/rbish/cli.rb, line 54 def parse_cli_arguments if target.nil? # requires filename when you don't have anything from $stdin raise OptionError, "Please specify file name." if $stdin.isatty @target = $stdin else begin @target = File.open(target, "r") rescue SystemCallError => e raise OptionError, "Couldn't open file #{target}." if $stdin.isatty end end end
target()
click to toggle source
Returns target File object.
# File lib/rbish/cli.rb, line 69 def target return cli_arguments.first end