simplify: support .xgrep file

This commit is contained in:
rkiel
2016-04-29 09:46:44 -04:00
parent 516f9222a6
commit b2e681f7b3
2 changed files with 10 additions and 6 deletions

View File

@@ -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

View File

@@ -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