simplify: support .xgrep file
This commit is contained in:
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
require_relative '../lib/xgrep/commander'
|
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?
|
if commander.valid?
|
||||||
commander.execute
|
commander.execute
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ module Xgrep
|
|||||||
|
|
||||||
@option_parser.parse!(argv)
|
@option_parser.parse!(argv)
|
||||||
options.terms = argv # must be after parse!
|
options.terms = argv # must be after parse!
|
||||||
|
|
||||||
if options.exclude_pathspec.size > 0 and options.include_pathspec.size == 0
|
if options.exclude_pathspec.size > 0 and options.include_pathspec.size == 0
|
||||||
options.pathspec = ['.'] + options.exclude_pathspec
|
options.pathspec = ['.'] + options.exclude_pathspec
|
||||||
else
|
else
|
||||||
@@ -115,12 +116,8 @@ module Xgrep
|
|||||||
private
|
private
|
||||||
|
|
||||||
def default_environment
|
def default_environment
|
||||||
if File.exist?('./.xgrep')
|
|
||||||
Xgrep::CustomEnv.new
|
|
||||||
else
|
|
||||||
Xgrep::SimpleEnv.new
|
Xgrep::SimpleEnv.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user