aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/options.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/options.rb')
-rw-r--r--lib/sisu/v3/options.rb76
1 files changed, 71 insertions, 5 deletions
diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb
index e57bf7fa..96ec3c4a 100644
--- a/lib/sisu/v3/options.rb
+++ b/lib/sisu/v3/options.rb
@@ -64,24 +64,90 @@ module SiSU_commandline
class Options
attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what
def initialize(a)
- @x=a
@cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path='','','','','','','','','','',''
@f_pths,@files,@paths,@mod,@act=Array.new(5){[]}
@env=SiSU_Env::Info_env.new
@dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by?
@@base_path ||=Dir.pwd
@base_path=@@base_path
+ @a=sisu_glob_rules(a)
+ @a.freeze
+ init
+ end
+ def find_all(find_flag,opt)
+ if find_flag
+ pwd_set=Dir.pwd
+ x=Dir.glob('*.ss[tm]')
+ Px[:lng_lst].each do |d|
+ if FileTest.directory?(d)
+ x << Dir.glob("#{d}/*.ss[tm]")
+ end
+ end
+ opt + x.flatten!
+ end
+ end
+ def find_select(find_flag,opt)
+ if find_flag
+ pwd_set=Dir.pwd
+ x=[]
+ if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/
+ opt.each do |g|
+ x <<=if g =~/.ss[tm]/
+ Dir.glob("*#{g}")
+ else
+ Dir.glob("*#{g}*.ss[tm]")
+ end
+
+ Px[:lng_lst].each do |d|
+ if FileTest.directory?(d)
+ x <<=if g =~/.ss[tm]/
+ Dir.glob("#{d}/*#{g}")
+ else
+ Dir.glob("#{d}/*#{g}*.ss[tm]")
+ end
+ end
+ end
+ end
+ end
+ x.flatten!
+ end
+ end
+ def sisu_glob_rules(a)
+ b=[]
+ f=[]
+ find_flag=false
+ a.each do |y|
+ if y =~ /^-/ \
+ or y =~ /\.ss[tm]$/
+ if y =~/^-/ \
+ && y =~/[fG]|--find|--glob/
+ find_flag=true
+ end
+ b << y
+ end
+ if find_flag \
+ && y !~ /^-/ \
+ && y =~ /\S+/
+ f << y
+ elsif y =~ /^-/
+ b << y
+ end
+ end
r=Px[:lng_lst].join('|')
r.gsub!(/\|en\|/,'|')
@lang_regx=%r{(?:#{r})}
- @a=if a.inspect =~/"(?:-\S+?|--\S+?)"/ \
+ z=if find_flag
+ if f.length > 0
+ b + find_select(find_flag,f)
+ else
+ find_all(find_flag,b)
+ end
+ elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \
&& a.inspect =~/"#{@lang_regx}\/?"/ \
&& a.inspect =~/"en\/\S+?\.ss[tm]"/
init_selected_lang_dirs(a)
- else @x
+ else b
end
- @a.freeze
- init
end
def init_selected_lang_dirs(a)
@z=[]