lib/sym/app/cli.rb in sym-3.0.0 vs lib/sym/app/cli.rb in sym-3.0.1
- old
+ new
@@ -56,11 +56,11 @@
# brings in #parse(Array[String] args)
include CLISlop
attr_accessor :opts, :application, :outputs, :stdin, :stdout, :stderr, :kernel, :args
- def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
+ def initialize(argv, stdin = $stdin, stdout = $stdout, stderr = $stderr, kernel = nil)
self.args = argv
self.stdin = stdin
self.stdout = stdout
self.stderr = stderr
self.kernel = kernel
@@ -77,19 +77,17 @@
Constants.user_home = opts[:user_home]
raise InvalidSymHomeDirectory, "#{opts[:user_home]} does not exist!" unless Dir.exist?(Constants.user_home)
end
# Deal with SYM_ARGS and -A
- if opts[:sym_args]
- if non_empty_array?(sym_args)
+ if opts[:sym_args] && non_empty_array?(sym_args)
args << sym_args
args.flatten!
args.compact!
args.delete('-A')
args.delete('--sym-args')
self.opts = parse(args)
- end
end
# Disable coloring if requested, or if piping STDOUT
if opts[:no_color] || !self.stdout.tty?
Colored2.disable! # reparse options without the colors to create new help msg
@@ -97,10 +95,10 @@
end
rescue StandardError => e
log :error, "#{e.message}" if opts
error exception: e
- quit!(127) if stdin == STDIN
+ quit!(127) if stdin == $stdin
end
self.application = ::Sym::Application.new(self.opts, stdin, stdout, stderr, kernel)
end