simplify: support .xgrep file
This commit is contained in:
@@ -2,7 +2,14 @@
|
||||
|
||||
require_relative '../lib/xgrep/commander'
|
||||
|
||||
commander = Xgrep::Commander.new(ARGV)
|
||||
if File.exist? './.xgrep'
|
||||
project_argv = File.read('./.xgrep').split(/\s/).reject { |x| x.strip == "" }
|
||||
argv = project_argv + ARGV
|
||||
else
|
||||
argv = ARGV
|
||||
end
|
||||
|
||||
commander = Xgrep::Commander.new(argv)
|
||||
if commander.valid?
|
||||
commander.execute
|
||||
else
|
||||
|
||||
@@ -59,6 +59,7 @@ module Xgrep
|
||||
|
||||
@option_parser.parse!(argv)
|
||||
options.terms = argv # must be after parse!
|
||||
|
||||
if options.exclude_pathspec.size > 0 and options.include_pathspec.size == 0
|
||||
options.pathspec = ['.'] + options.exclude_pathspec
|
||||
else
|
||||
@@ -115,11 +116,7 @@ module Xgrep
|
||||
private
|
||||
|
||||
def default_environment
|
||||
if File.exist?('./.xgrep')
|
||||
Xgrep::CustomEnv.new
|
||||
else
|
||||
Xgrep::SimpleEnv.new
|
||||
end
|
||||
Xgrep::SimpleEnv.new
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user