c&d: pass info needed make run better without install
[software/sisu] / lib / sisu / current / hub_options.rb
1 # encoding: utf-8
2 =begin
3
4 * Name: SiSU
5
6 ** Description: documents, structuring, processing, publishing, search
7 *** hub, command line options parsing
8
9 *** hub
10
11 ** Author: Ralph Amissah
12 <ralph@amissah.com>
13 <ralph.amissah@gmail.com>
14
15 ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
16 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
17 All Rights Reserved.
18
19 ** License: GPL 3 or later:
20
21 SiSU, a framework for document structuring, publishing and search
22
23 Copyright (C) Ralph Amissah
24
25 This program is free software: you can redistribute it and/or modify it
26 under the terms of the GNU General Public License as published by the Free
27 Software Foundation, either version 3 of the License, or (at your option)
28 any later version.
29
30 This program is distributed in the hope that it will be useful, but WITHOUT
31 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
32 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
33 more details.
34
35 You should have received a copy of the GNU General Public License along with
36 this program. If not, see <http://www.gnu.org/licenses/>.
37
38 If you have Internet connection, the latest version of the GPL should be
39 available at these locations:
40 <http://www.fsf.org/licensing/licenses/gpl.html>
41 <http://www.gnu.org/licenses/gpl.html>
42
43 <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
44
45 ** SiSU uses:
46 * Standard SiSU markup syntax,
47 * Standard SiSU meta-markup syntax, and the
48 * Standard SiSU object citation numbering and system
49
50 ** Hompages:
51 <http://www.jus.uio.no/sisu>
52 <http://www.sisudoc.org>
53
54 ** Git
55 <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
56 <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/hub_options.rb;hb=HEAD>
57
58 =end
59 module SiSU_Commandline
60 begin
61 require 'pathname'
62 rescue LoadError
63 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
64 error('pathname NOT FOUND (LoadError)')
65 end
66 require_relative 'se' # se.rb
67 require_relative 'dp_make' # dp_make.rb
68 class HeaderCommon
69 def sisu_document_make_instructions(make_instruct_array=:nil)
70 @pagenew=
71 @pagebreak=
72 @pageline=
73 @toc=
74 @lv1=@lv2=@lv3=@lv4=@lv5=@lv6=
75 @num_top=
76 @i18n=
77 @man_section=
78 @emphasis_set_to=
79 @bold_match_list=
80 @italics_match_list=
81 @substitution_match_list=
82 @footer_links=
83 @home_button_links=
84 @links=
85 nil
86 make_instruct_array=make_instruct_array==:nil \
87 ? SiSU_Env::GetInit.new.sisu_document_make.makefile_read
88 : make_instruct_array
89 @makeset=false
90 if make_instruct_array
91 make_instruct_array.each do |para| #% scan document
92 if para =~/^(?:@make:|@links:)[+-]?\s/
93 case para
94 when /^@make:(.+)/m #% header processing - make
95 @env=SiSU_Env::InfoEnv.new
96 @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make
97 makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct
98 @makeset=true
99 @pagenew=makes[:pagenew]
100 @pagebreak=makes[:pagenew]
101 @pageline=makes[:pageline]
102 @toc=makes[:toc]
103 @lv1=makes[:lv1]
104 @lv2=makes[:lv2]
105 @lv3=makes[:lv3]
106 @lv4=makes[:lv4]
107 @lv5=makes[:lv5]
108 @lv6=makes[:lv6]
109 @num_top=makes[:num_top]
110 @i18n=makes[:i18n]
111 @man_section=makes[:man_section]
112 @emphasis_set_to=makes[:emphasis_set_to]
113 @bold_match_list=makes[:bold_match_list]
114 @italics_match_list=makes[:italics_match_list]
115 @substitution_match_list=makes[:substitution_match_list]
116 @footer_links=makes[:footer_links]
117 @home_button_links=makes[:home_button_links]
118 @home_button_image=makes[:home_button_image]
119 @cover_image=makes[:cover_image]
120 when /^@links:(.+)/m #% header processing - make
121 make_links=SiSU_Param::Parameters::MdMake.new($1.strip,@opt,@env).make_links
122 @links,@links_append=make_links.links,make_links.append?
123 end
124 end
125 end #% here endeth the common header loop
126 end
127 { makeset: @makeset,
128 pagenew: @pagenew,
129 pagebreak: @pagebreak,
130 pageline: @pageline,
131 toc: @toc,
132 lv1: @lv1,
133 lv2: @lv2,
134 lv3: @lv3,
135 lv4: @lv4,
136 lv5: @lv5,
137 lv6: @lv6,
138 num_top: @num_top,
139 i18n: @i18n,
140 man_section: @man_section,
141 emphasis_set_to: @emphasis_set_to,
142 bold_match_list: @bold_match_list,
143 italics_match_list: @italics_match_list,
144 substitution_match_list: @substitution_match_list,
145 footer_links: @footer_links,
146 home_button_links: @home_button_links,
147 home_button_image: @home_button_image,
148 cover_image: @cover_image,
149 links: @links,
150 links_append: @links_append
151 }
152 end
153 end
154 class Options
155 attr_accessor :selections,:opt_ch,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod,:sisu_run_path,:sisu_install_type
156 @@act=nil
157 def initialize(a,sisu_runtime)
158 @opt_ch=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location=''
159 @f_pths,@files,@files_mod,@paths,@select_arr,@act=Array.new(5){[]}
160 @select_str=nil
161 @env=SiSU_Env::InfoEnv.new
162 @lng_base=@env.language_default_set
163 @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by?
164 @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual?
165 @sisu_run_from=sisu_runtime[:runtime_path]
166 @sisu_install_type=sisu_runtime[:runtime_type]
167 @call_path=sisu_runtime[:call_path]
168 pth=SiSU_Utils::Path.new(call_path)
169 @base_path=pth.base_markup
170 @base_stub=pth.base_markup_stub
171 @image_src_path=pth.image_src
172 @a=sisu_glob_rules(a)
173 @a.freeze
174 @make_instructions=HeaderCommon.new.sisu_document_make_instructions
175 @make_instructions_pod=nil
176 init
177 end
178 def sisu_run_from?
179 @sisu_run_from
180 end
181 def sisu_install_type?
182 @sisu_install_type
183 end
184 def find_all(find_flag,opt)
185 if find_flag
186 x=Dir.glob('*.ss[tm]')
187 Px[:lng_lst].each do |d|
188 if FileTest.directory?(d)
189 x << Dir.glob("#{d}/*.ss[tm]")
190 end
191 end
192 x=x.flatten
193 opt + x
194 end
195 end
196 def find_select(find_flag,opt)
197 if find_flag
198 x=[]
199 if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/
200 opt.each do |g|
201 x <<=if g =~/.ss[tm]/
202 Dir.glob("*#{g}")
203 else
204 Dir.glob("*#{g}*.ss[tm]")
205 end
206 Px[:lng_lst].each do |d|
207 if FileTest.directory?(d)
208 x <<=if g =~/.ss[tm]/
209 Dir.glob("#{d}/*#{g}")
210 else
211 Dir.glob("#{d}/*#{g}*.ss[tm]")
212 end
213 end
214 end
215 end
216 end
217 x.flatten
218 end
219 end
220 def sisu_glob_rules(a)
221 a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \
222 or a.inspect =~/"--find"|"--glob"/
223 b,f=[],[]
224 find_flag=false
225 a.each do |y|
226 if y =~ /^-/
227 if y =~/^-/ \
228 && y =~/[fG]|--find|--glob/
229 find_flag=true
230 end
231 b << y
232 end
233 if find_flag \
234 && y !~ /^-/ \
235 && y =~ /\S+/
236 if y !~/\//
237 f << y
238 else
239 find_flag=false
240 puts %{sub-directories "#{y}" cannot be provided for --find or --glob at this time}
241 end
242 end
243 end
244 r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|')
245 @lang_regx=%r{(?:#{r})}
246 if find_flag
247 (f.length > 0) \
248 ? (b + find_select(find_flag,f))
249 : find_all(find_flag,b)
250 elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \
251 && a.inspect =~/"#{@lang_regx}\/?"/ \
252 && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/
253 init_selected_lang_dirs(a)
254 else b
255 end
256 else a
257 end
258 end
259 def init_selected_lang_dirs(a)
260 @z=[]
261 a.each do |y|
262 if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/
263 @fn=$1
264 @z << y
265 elsif y =~/^#{@lang_regx}\/?$/
266 @z << "#{y}/#{@fn}"
267 else @z << y
268 end
269 end
270 @z
271 end
272 def init
273 a=@a
274 s=expand_numeric_shortcuts(a)
275 q=set_files_and_paths_and_general_extract(s)
276 files=(q[:files].length > 0) ? :true : :false
277 @select_arr=opt_cmd_and_mod_adjust(q[:opt_ch],q[:selections],files)
278 if a.length > 0
279 @what=q[:what] unless q[:what].empty?
280 @paths = q[:paths]
281 @files = q[:files]
282 @f_pths = q[:f_pths]
283 @lngs = q[:lngs]
284 if @files.length > 0 \
285 and @opt_ch.empty? \
286 and @select_arr.length==0 #% if no other action called on filename given, default is sisu --v5 -0 [filename(s)] configured as flag default
287 shortcut=SiSU_Env::InfoProcessingFlag.new
288 @select_arr=['--v5']
289 @select_arr << shortcut.act_0.arr #+ ' --dal'
290 end
291 if @select_arr.inspect =~/--verbose/ \
292 && @opt_ch !~/-[ku]*v[ku]*$/
293 SiSU_Screen::Ansi.new(
294 @opt_ch,
295 "\tsisu " + @opt_ch + ' ' + @select_arr.join(' ') + ' ' + @files.join(' ') + "\n"
296 ).print_brown
297 end
298 end
299 @@act ? @act=@@act : @@act=@act=opt_act
300 self
301 end
302 def sisu_document_make_pod
303 def makefile_name
304 SiSU_Env::GetInit.new.sisu_document_make.makefile_name
305 end
306 def makefile(pod_make_path)
307 "#{pod_make_path}/#{makefile_name}"
308 end
309 def makefile_read(pod_make_path)
310 if FileTest.file?(makefile(pod_make_path))
311 sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8')
312 sisu_doc_makefile.split(/\s*\n\s*\n/m)
313 else nil
314 end
315 end
316 self
317 end
318 def set_files_and_paths_and_general_extract(s)
319 c,w='',''
320 m,f,pth,lng,lngs=[],[],[],[],[]
321 lng_is=''
322 a=(s.nil?) \
323 ? ['-v']
324 : s.split(/\s+/)
325 r_l=Px[:lng_lst].join('|')
326 a.uniq.each do |x|
327 if x =~/^-[a-z0-5]+/i \
328 or x =~/^--\S+/
329 if x =~/^-([a-z0-5]+)/i
330 c << $1
331 end
332 if x =~/^--\S+/
333 m << x
334 end
335 elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/
336 if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/
337 if x =~/^(?:https?|file):\/\/\S+/ #\
338 end
339 pwd=Dir.pwd
340 fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1')
341 fullname=@env.processing_path.processing + '/sisupod/' + fn_pod
342 pt=Pathname.new(fullname)
343 FileUtils::mkdir_p(pt.to_s)
344 pod_make_path=fullname + '/sisupod/doc/_sisu'
345 make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path)
346 @make_instructions_pod=
347 HeaderCommon.new.sisu_document_make_instructions(make_instruct_array)
348 Dir.chdir(pt.realpath)
349 system("
350 chdir #{fullname}
351 tar xaf #{pwd}/#{x}
352 chdir #{pwd}
353 ")
354 Dir.chdir(pt.realpath.to_s + '/sisupod/doc')
355 r=Px[:lng_lst_rgx]
356 Dir.entries("#{fullname}/sisupod/doc").each do |d_lng|
357 if d_lng =~/^(?:#{r})$/
358 Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}")
359 filenames=Dir.glob("*.ss[mt]")
360 filenames.each do |fn|
361 f_pths << {
362 pth: "#{fullname}/sisupod/doc/#{d_lng}",
363 f: "#{fn}",
364 pth_stub: 'doc',
365 lng: d_lng,
366 lng_is: d_lng,
367 url_base: '',
368 url: ''
369 }
370 Dir.chdir(pwd)
371 f << fn
372 end
373 end
374 end
375 elsif x =~/^(?:https?|file):\/\/\S+/ \
376 and x =~/\S+?\.ss[mt]$/
377 r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\//
378 url_base = (x[r_url,1])
379 url = x
380 y=x.gsub(/http:\/\/\S+?\/\S+?\/src\//,'')
381 t=/(#{r_l})\/[^\/]+?\.ss[tm]$/
382 l_p = (y[t,1]) \
383 ? y[t,1]
384 : nil
385 lng << l_p
386 lngs << if l_p
387 l_p
388 elsif x =~/~(#{r_l})\.ss[tm]/
389 $1
390 else lng_base
391 end
392 r_f=/(?:#{r_l})\/([^\/]+?\.ss[tm])$/
393 fn = (y[r_f,1]) \
394 ? y[r_f,1]
395 : y
396 fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1')
397 fullname=Dir.pwd + '/' + fn
398 pt=Pathname.new(fullname)
399 pth << Dir.pwd
400 r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/
401 lng_is =if l_p
402 l_p
403 elsif x =~/~(#{r_l})\.ss[tm]/
404 $1
405 else lng_base
406 end
407 f_pths << {
408 pth: pt.split[0].realpath.to_s,
409 f: pt.split[1].to_s,
410 pth_stub: pt.split[0].realpath.to_s[r_u,1],
411 lng: (pt.split[0].realpath.to_s[t,1]) \
412 ? pt.split[0].realpath.to_s[t,1]
413 : nil,
414 lng_is: lng_is,
415 url_base: url_base,
416 url: url
417 }
418 f << fn
419 elsif FileTest.file?(x)
420 pt=Pathname.new(x)
421 pth << pt.split[0].realpath.to_s #remove?
422 f << pt.split[1].to_s #remove?
423 r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/
424 t=/.+\/(#{r_l})$/
425 l_p = (pt.split[0].realpath.to_s[t,1]) \
426 ? pt.split[0].realpath.to_s[t,1]
427 : nil
428 lngs << lng_is = if l_p
429 l_p
430 elsif x =~/~(#{r_l})\.ss[tm]/
431 $1
432 else lng_base
433 end
434 f_pths << {
435 pth: pt.split[0].realpath.to_s,
436 f: pt.split[1].to_s,
437 pth_stub: pt.split[0].realpath.to_s[r_u,1],
438 lng: lng_is,
439 lng_is: lng_is,
440 url_base: nil,
441 url: nil,
442 }
443 else puts "file not found: #{x}"
444 end
445 elsif x =~ /\.termsheet\.rb$/
446 (FileTest.file?(x)) \
447 ? (f << x)
448 : (puts "file not found: #{x}")
449 else w=x
450 puts "#{x} in #{a.join(' ')}?"
451 end
452 end
453 {
454 opt_ch: c,
455 selections: m,
456 what: w,
457 paths: pth,
458 files: f,
459 f_pths: f_pths,
460 lng: lng_is,
461 lngs: lngs,
462 }
463 end
464 def expand_numeric_shortcuts(a)
465 s=''
466 a.each do |x|
467 y=case x
468 when /0/
469 (x=~/^-0\S+/) \
470 ? x.gsub(/^-0(\S+)/,'--act0' + ' -\1')
471 : x.gsub(/^-0/,'--act0' + ' ')
472 when /1/
473 (x=~/^-1\S+/) \
474 ? x.gsub(/^-1(\S+)/,'--act1' + ' -\1')
475 : x.gsub(/^-1/,'--act1' + ' ')
476 when /2/
477 (x=~/^-2\S+/) \
478 ? x.gsub(/^-2(\S+)/,'--act2' + ' -\1')
479 : x.gsub(/^-2/,'--act2' + ' ')
480 when /3/
481 (x=~/^-3\S+/) \
482 ? x.gsub(/^-3(\S+)/,'--act3' + ' -\1')
483 : x.gsub(/^-3/,'--act3' + ' ')
484 when /4/
485 (x=~/^-4\S+/) \
486 ? x.gsub(/^-4(\S+)/,'--act4' + ' -\1')
487 : x.gsub(/^-4/,'--act4' + ' ')
488 when /5/
489 (x=~/^-5\S+/) \
490 ? x.gsub(/^-5(\S+)/,'--act5' + ' -\1')
491 : x.gsub(/^-5/,'--act5' + ' ')
492 when /6/
493 (x=~/^-6\S+/) \
494 ? x.gsub(/^-6(\S+)/,'--act6' + ' -\1')
495 : x.gsub(/^-6/,'--act6' + ' ')
496 when /7/
497 (x=~/^-7\S+/) \
498 ? x.gsub(/^-7(\S+)/,'--act7' + ' -\1')
499 : x.gsub(/^-7/,'--act7' + ' ')
500 when /8/
501 (x=~/^-8\S+/) \
502 ? x.gsub(/^-8(\S+)/,'--act8' + ' -\1')
503 : x.gsub(/^-8/,'--act8' + ' ')
504 when /9/
505 (x=~/^-9\S+/) \
506 ? x.gsub(/^-9(\S+)/,'--act9' + ' -\1')
507 : x.gsub(/^-9/,'--act9' + ' ')
508 else x
509 end
510 s << " #{y}" unless y.empty?
511 end
512 s.strip!
513 end
514 def opt_cmd_and_mod_adjust(ch,select_arr,files)
515 select_arr=select_arr.flatten
516 sel_init=select_arr.flatten
517 shortcut=SiSU_Env::InfoProcessingFlag.new
518 if files ==:true
519 if not sel_init.empty? \
520 and sel_init.inspect =~/"--act[s0-9]?/
521 sel_init.each do |s|
522 select_arr <<=case s
523 when /--act0/ then shortcut.act_0.arr
524 when /--act1/ then shortcut.act_1.arr
525 when /--act2/ then shortcut.act_2.arr
526 when /--act3/ then shortcut.act_3.arr
527 when /--act4/ then shortcut.act_4.arr
528 when /--act5/ then shortcut.act_5.arr
529 when /--act6/ then shortcut.act_6.arr
530 when /--act7/ then shortcut.act_7.arr
531 when /--act8/ then shortcut.act_8.arr
532 when /--act9/ then shortcut.act_9.arr
533 when /--act/ then shortcut.act_info
534 end
535 end
536 end
537 if not sel_init.empty? \
538 and sel_init.inspect =~/"--pdf-/
539 select_arr << '--pdf'
540 sel_init.each do |s|
541 if s =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/
542 select_arr << '--landscape'
543 end
544 if s =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/
545 select_arr << '--portrait'
546 end
547 if s =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/
548 if s =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/
549 select_arr << '--papersize-a4'
550 end
551 if s =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/
552 select_arr << '--papersize-a5'
553 end
554 if s =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/
555 select_arr << '--papersize-b5'
556 end
557 if s =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/
558 select_arr << '--papersize-letter'
559 end
560 if s =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/
561 select_arr << '--papersize-legal'
562 end
563 end
564 end
565 select_arr=select_arr.uniq
566 end
567 if ch.empty? \
568 and sel_init.length == 0
569 select_arr << shortcut.act_0.arr ################ & --flag empty
570 elsif not ch.empty?
571 if ch =~/c/ then select_arr << '--color-toggle'
572 ch=ch.gsub(/[c]/,'')
573 end
574 if ch =~/k/ then select_arr << '--color-off'
575 ch=ch.gsub(/[k]/,'')
576 end
577 if ch =~/C/ then select_arr << '--config'
578 ch=ch.gsub(/[C]+/,'')
579 end
580 if ch =~/m/ then select_arr << '--dal'
581 ch=ch.gsub(/[m]/,'')
582 end
583 if ch =~/t/ then select_arr << '--txt'
584 ch=ch.gsub(/[t]/,'')
585 end
586 if ch =~/h/ then select_arr << '--html'
587 ch=ch.gsub(/[h]/,'')
588 end
589 if ch =~/e/ then select_arr << '--epub'
590 ch=ch.gsub(/[e]/,'')
591 end
592 if ch =~/o/ then select_arr << '--odt'
593 ch=ch.gsub(/[o]/,'')
594 end
595 if ch =~/d/ then select_arr << '--docbook'
596 ch=ch.gsub(/[d]/,'')
597 end
598 if ch =~/p/ then select_arr << '--pdf'
599 ch=ch.gsub(/[p]/,'')
600 end
601 if ch =~/w/ then select_arr << '--concordance'
602 ch=ch.gsub(/[w]/,'')
603 end
604 if ch =~/i/ then select_arr << '--manpage'
605 ch=ch.gsub(/[i]/,'')
606 end
607 if ch =~/I/ then select_arr << '--texinfo'
608 ch=ch.gsub(/[I]/,'')
609 end
610 if ch =~/b/ then select_arr << '--xhtml'
611 ch=ch.gsub(/[b]/,'')
612 end
613 if ch =~/x/ then select_arr << '--xml-sax'
614 ch=ch.gsub(/[x]/,'')
615 end
616 if ch =~/X/ then select_arr << '--xml-dom'
617 ch=ch.gsub(/[X]/,'')
618 end
619 if ch =~/j/ then select_arr << '--images'
620 ch=ch.gsub(/[j]/,'')
621 end
622 if ch =~/N/ then select_arr << '--digests'
623 ch=ch.gsub(/[N]/,'')
624 end
625 if ch =~/P/ then select_arr << '--po4a'
626 ch=ch.gsub(/[P]/,'')
627 end
628 if ch =~/d/ then select_arr << '--sqlite'
629 ch=ch.gsub(/[d]/,'')
630 end
631 if ch =~/D/ then select_arr << '--pg'
632 ch=ch.gsub(/[D]/,'')
633 end
634 if ch =~/Q/ then select_arr << '--qrcode'
635 ch=ch.gsub(/[Q]/,'')
636 end
637 if ch =~/s/ then select_arr << '--source'
638 ch=ch.gsub(/[s]/,'')
639 end
640 if ch =~/S/ then select_arr << '--sisupod'
641 ch=ch.gsub(/[S]/,'')
642 end
643 if ch =~/m/ then select_arr << '--manifest'
644 ch=ch.gsub(/[m]/,'')
645 end
646 if ch =~/R/ then select_arr << '--rsync'
647 ch=ch.gsub(/[R]/,'')
648 end
649 if ch =~/r/ then select_arr << '--scp'
650 ch=ch.gsub(/[r]/,'')
651 end
652 if ch =~/g/ then select_arr << '--git'
653 ch=ch.gsub(/[g]/,'')
654 end
655 if ch =~/U/ then select_arr << '--urls'
656 ch=ch.gsub(/[u]/,'')
657 end
658 if ch =~/Z/ then select_arr << '--zap'
659 ch=ch.gsub(/[Z]/,'')
660 end
661 if ch =~/F/ then select_arr << '--sample-search-form'
662 ch=ch.gsub(/[F]/,'')
663 end
664 if ch =~/W/ then select_arr << '--webrick'
665 ch=ch.gsub(/[w]/,'')
666 end
667 if ch =~/M/ then select_arr << '--maintenance'
668 ch=ch.gsub(/[M]/,'')
669 end
670 if ch =~/V/ then select_arr << '--very-verbose'
671 ch=ch.gsub(/[V]/,'')
672 end
673 if ch =~/v/ then select_arr << '--verbose'
674 ch=ch.gsub(/[v]/,'')
675 end
676 if ch =~/q/ then select_arr << '--quiet'
677 ch=ch.gsub(/[q]/,'')
678 end
679 if select_arr.inspect !~/--urls/ \
680 and select_arr.inspect \
681 !~/"--harvest/
682 select_arr << '--urls'
683 end
684 if select_arr.inspect !~/--dal/ \
685 and select_arr.inspect =~/txt|text|html|odt|epub|docbook|xml|pdf|manpage|texinfo|concordance|qrcode|source|sisupod|pg|sqlite|zap/
686 select_arr << '--dal'
687 end
688 if select_arr.inspect !~/--manifest/ \
689 and select_arr.inspect =~/txt|text|html|odt|epub|docbook|xml|pdf|manpage|texinfo|concordance|qrcode|source|sisupod|pg|sqlite|zap/
690 select_arr << '--manifest'
691 end
692 if select_arr.inspect !~/--images/ \
693 and select_arr.inspect =~/html|odt|docbook|xml|qrcode/
694 select_arr << '--images'
695 end
696 end
697 else
698 if not sel_init.empty? \
699 and sel_init.inspect =~/"--acts?/
700 shortcut.act_info
701 exit
702 end
703 if ch =~/c/ then select_arr << '--color-toggle'
704 ch=ch.gsub(/[c]/,'')
705 end
706 if ch =~/k/ then select_arr << '--color-off'
707 ch=ch.gsub(/[k]/,'')
708 end
709 if ch =~/C/ then select_arr << '--config'
710 ch=ch.gsub(/[C]+/,'')
711 end
712 if sel_init.inspect =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"/
713 if ch =~/d/ then select_arr << '--sqlite'
714 ch=ch.gsub(/[d]/,'')
715 end
716 if ch =~/D/ then select_arr << '--pg'
717 ch=ch.gsub(/[D]/,'')
718 end
719 end
720 if ch =~/W/ then select_arr << '--webrick'
721 ch=ch.gsub(/[w]/,'')
722 end
723 if ch =~/v/ then select_arr << '--version'
724 ch=ch.gsub(/[v]/,'')
725 end
726 if ch =~/M/ then select_arr << '--maintenance'
727 ch=ch.gsub(/[M]/,'')
728 end
729 if ch =~/V/ then select_arr << '--very-verbose'
730 ch=ch.gsub(/[V]/,'')
731 end
732 if ch =~/q/ then select_arr << '--quiet'
733 ch=ch.gsub(/[q]/,'')
734 end
735 end
736 select_arr=select_arr.flatten.compact.uniq.sort
737 end
738 def opt_act
739 select_arr=@select_arr
740 @@act=if @@act
741 @act=@@act
742 else
743 act={}
744 act[:no_stop]=if select_arr.inspect \
745 =~/"--no-stop"|"--errors-as-warnings"/
746 { bool: true, set: :on }
747 else
748 { bool: false, set: :na }
749 end
750 act[:license]=(select_arr.inspect \
751 =~/"--license/) \
752 ? { bool: true, set: :on }
753 : { bool: false, set: :na }
754 act[:site_init]=(select_arr.inspect \
755 =~/"--init"|"--initialize"|"--init-site"|"--conf"|"--config"|"--configure"/) \
756 ? { bool: true, set: :on }
757 : { bool: false, set: :na }
758 act[:rc]=if select_arr.inspect \
759 =~/"--rc=/
760 x=Dir.pwd + '/' + select_arr.join.gsub(/--rc=/,'')
761 { bool: true, set: :on, inst: x }
762 else
763 { bool: false, set: :na, inst: '' }
764 end
765 act[:processing_path]=if select_arr.inspect \
766 =~/"--processing-path=/
767 base_pth=select_arr.join(';').gsub(/^.*--processing-path=['"]?(.+?)(?:['"]?;.+)?$/,'\1')
768 { bool: true, set: :on, inst: base_pth }
769 elsif select_arr.inspect \
770 =~/"--processing-path/
771 { bool: true, set: :on, inst: @base_path }
772 else
773 { bool: false, set: :na, inst: nil }
774 end
775 act[:dump]=if select_arr.inspect \
776 =~/"--dump=/
777 base_pth=select_arr.join(';').
778 gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1')
779 { bool: true, set: :on, inst: base_pth }
780 elsif select_arr.inspect =~/"--dump/
781 { bool: true, set: :on, inst: @base_path }
782 else
783 { bool: false, set: :na, inst: nil }
784 end
785 act[:redirect]=if select_arr.inspect \
786 =~/"--redirect=/
787 base_pth=select_arr.join(';').
788 gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1')
789 { bool: true, set: :on, inst: base_pth }
790 elsif select_arr.inspect \
791 =~/"--redirect/
792 { bool: true, set: :on, inst: @base_path }
793 else
794 { bool: false, set: :na, inst: nil }
795 end
796 act[:switch]=if select_arr.inspect \
797 =~/"--switch-off=/
798 off_list=select_arr.join(';').
799 gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1')
800 off_list=off_list.scan(/[^,;\s]+/)
801 { bool: false, set: :off, off: off_list}
802 else { bool: true, set: :na, off: [] }
803 end
804 act[:default_language]=if select_arr.inspect \
805 =~/"--(?:default-)?language[-=](\S{2})"/
806 { set: :on, code: $1 }
807 elsif lng_base
808 { set: :on, code: lng_base }
809 else { set: :na, code: 'en' }
810 end
811 act[:i18n]=if select_arr.inspect \
812 =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected
813 @lingual=:mono
814 { set: :mono }
815 elsif select_arr.inspect \
816 =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/
817 @lingual=:multi
818 { set: :multi }
819 else { set: :na }
820 end
821 act[:output_by]=if select_arr.inspect \
822 =~/"--(?:output-)?by-language"/
823 @dir_structure_by=:language
824 { set: :language }
825 elsif select_arr.inspect \
826 =~/"--(?:output-)?by-filename"/
827 @dir_structure_by=:filename
828 { set: :filename }
829 elsif select_arr.inspect \
830 =~/"--(?:output-)?by-filetype"/
831 @dir_structure_by=:filetype
832 { set: :filetype }
833 else { set: :na }
834 end
835 act[:ocn]=if select_arr.inspect \
836 =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/
837 { bool: true, set: :on }
838 elsif select_arr.inspect \
839 =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ \
840 || act[:switch][:off].inspect =~/"ocn"|"--numbering"/
841 { bool: false, set: :off }
842 else { bool: true, set: :na }
843 end
844 act[:toc]=if select_arr.inspect \
845 =~/"--inc-toc"/
846 { bool: true, set: :on }
847 elsif select_arr.inspect \
848 =~/"--(?:exc|no)-toc"/ \
849 || act[:switch][:off].inspect =~/"toc"/
850 { bool: false, set: :off }
851 else { bool: true, set: :na }
852 end
853 act[:minitoc]=if select_arr.inspect \
854 =~/"--inc-minitoc"/
855 { bool: true, set: :on }
856 elsif select_arr.inspect \
857 =~/"--(?:exc|no)-minitoc"/ \
858 || act[:switch][:off].inspect =~/"minitoc"/
859 { bool: false, set: :off }
860 else { bool: true, set: :na }
861 end
862 act[:links_to_manifest]=if select_arr.inspect \
863 =~/"--inc-links-to-manifest"|"--inc-manifest-links"/
864 { bool: true, set: :on }
865 elsif select_arr.inspect \
866 =~/"--(?:exc|no)-manifest"/ \
867 || act[:switch][:off].inspect =~/"manifest"/ #place lower
868 { bool: false, set: :off }
869 elsif select_arr.inspect \
870 =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \
871 || act[:switch][:off].inspect \
872 =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \
873 || select_arr.inspect \
874 =~/"--(?:redirect|dump)/
875 { bool: false, set: :off }
876 else { bool: true, set: :na }
877 end
878 act[:manifest_minitoc]=if select_arr.inspect \
879 =~/"--inc-manifest-minitoc"|"--inc-minitoc"/
880 { bool: true, set: :on }
881 elsif select_arr.inspect \
882 =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \
883 || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/
884 { bool: false, set: :off }
885 else { bool: true, set: :na }
886 end
887 act[:metadata]=if select_arr.inspect \
888 =~/"--inc-metadata"/
889 { bool: true, set: :on }
890 elsif select_arr.inspect \
891 =~/"--(?:exc|no)-metadata"/ \
892 || act[:switch][:off].inspect =~/"metadata"/
893 { bool: false, set: :off }
894 else { bool: true, set: :na }
895 end
896 act[:html_minitoc]=if select_arr.inspect \
897 =~/"--inc-html-minitoc"|"--inc-minitoc"/
898 { bool: true, set: :on }
899 elsif select_arr.inspect \
900 =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \
901 || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/
902 { bool: false, set: :off }
903 else { bool: true, set: :na }
904 end
905 act[:html_navigation]=if select_arr.inspect \
906 =~/"--inc-html-navigation"|"--inc-navigation"/
907 { bool: true, set: :on }
908 elsif select_arr.inspect \
909 =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \
910 || act[:switch][:off].inspect =~/"html_navigation"|"nav"/
911 { bool: false, set: :off }
912 else { bool: true, set: :na }
913 end
914 act[:html_navigation_bar]=if select_arr.inspect \
915 =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/
916 { bool: true, set: :on }
917 elsif select_arr.inspect \
918 =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \
919 || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/
920 { bool: false, set: :off }
921 else { bool: false, set: :na }
922 end
923 act[:segsubtoc]=if select_arr.inspect \
924 =~/"--inc-segsubtoc"/
925 { bool: true, set: :on }
926 elsif select_arr.inspect \
927 =~/"--(?:exc|no)-segsubtoc"/ \
928 || act[:switch][:off].inspect =~/"segsubtoc"/
929 { bool: false, set: :off }
930 else { bool: true, set: :na }
931 end
932 act[:search_form]=if select_arr.inspect \
933 =~/"--inc-search-form"/
934 { bool: true, set: :on }
935 elsif select_arr.inspect \
936 =~/"--(?:exc|no)-search-form"/ \
937 || act[:switch][:off].inspect =~/"search_form"|"search"/
938 { bool: false, set: :off }
939 else { bool: true, set: :na }
940 end
941 act[:html_search_form]=if select_arr.inspect \
942 =~/"--inc-html-search-form"|"--inc-search-form"/
943 { bool: true, set: :on }
944 elsif select_arr.inspect \
945 =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \
946 || act[:switch][:off].inspect \
947 =~/"html_search_form"|"search_form"|"search"/
948 { bool: false, set: :off }
949 else { bool: true, set: :na }
950 end
951 act[:html_right_pane]=if select_arr.inspect \
952 =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/
953 { bool: true, set: :on }
954 elsif select_arr.inspect \
955 =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \
956 || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/
957 { bool: false, set: :off }
958 else { bool: true, set: :na }
959 end
960 act[:html_top_band]=if select_arr.inspect \
961 =~/"--inc-html-top-band"|"--inc-top-band"/
962 { bool: true, set: :on }
963 elsif select_arr.inspect \
964 =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \
965 || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/
966 { bool: false, set: :off }
967 else { bool: true, set: :na }
968 end
969 act[:html]=if select_arr.inspect \
970 =~/"--html-strict"/ \
971 or ((select_arr.inspect \
972 =~/"--html"/) \
973 && select_arr.inspect \
974 =~/"--strict"/)
975 act[:html_strict]={ bool: true, set: :on }
976 act[:html_scroll]={ bool: true, set: :on }
977 act[:html_seg]={ bool: true, set: :on }
978 { bool: true, set: :on }
979 elsif (select_arr.inspect \
980 =~/"--html"/)
981 act[:html_strict]={ bool: false, set: :off }
982 act[:html_scroll]={ bool: true, set: :on }
983 act[:html_seg]={ bool: true, set: :on }
984 { bool: true, set: :on }
985 else
986 act[:html_strict]=(select_arr.inspect \
987 =~/"--strict"/) \
988 ? { bool: true, set: :on }
989 : { bool: false, set: :na }
990 act[:html_scroll]=(select_arr.inspect \
991 =~/"--html-scroll"/) \
992 ? { bool: true, set: :on }
993 : { bool: false, set: :na }
994 act[:html_seg]=(select_arr.inspect \
995 =~/"--html-seg"/) \
996 ? { bool: true, set: :on }
997 : { bool: false, set: :na }
998 { bool: false, set: :na }
999 end
1000 act[:concordance]=(select_arr.inspect \
1001 =~/"--concordance"/) \
1002 ? { bool: true, set: :on }
1003 : { bool: false, set: :na }
1004 act[:images]=(select_arr.inspect \
1005 =~/"--images"/) \
1006 ? { bool: true, set: :on }
1007 : { bool: false, set: :na }
1008 if select_arr.inspect \
1009 =~/"--pdf"/
1010 if select_arr.inspect \
1011 =~/"--portrait"/
1012 act[:pdf]= { bool: false, set: :na }
1013 act[:pdf_l]={ bool: false, set: :na }
1014 act[:pdf_p]={ bool: true, set: :on }
1015 elsif select_arr.inspect \
1016 =~/"--landscape"/
1017 act[:pdf]= { bool: false, set: :na }
1018 act[:pdf_l]={ bool: true, set: :on }
1019 act[:pdf_p]={ bool: false, set: :na }
1020 else
1021 act[:pdf]= { bool: true, set: :on }
1022 act[:pdf_l]={ bool: true, set: :on }
1023 act[:pdf_p]={ bool: true, set: :on }
1024 end
1025 else
1026 act[:pdf]= { bool: false, set: :na }
1027 act[:pdf_p]= { bool: false, set: :na }
1028 act[:pdf_l]= { bool: false, set: :na }
1029 act[:pdf_a4]= { bool: false, set: :na }
1030 act[:pdf_a5]= { bool: false, set: :na }
1031 act[:pdf_b5]= { bool: false, set: :na }
1032 act[:pdf_letter]={ bool: false, set: :na }
1033 act[:pdf_legal]= { bool: false, set: :na }
1034 end
1035 if act[:pdf][:set]==:on \
1036 or act[:pdf_p][:set]==:on \
1037 or act[:pdf_l][:set]==:on
1038 act[:pdf_a4]=if select_arr.inspect \
1039 =~/"--a4"|--papersize-a4"/ \
1040 or select_arr.inspect \
1041 =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5
1042 { bool: true, set: :on }
1043 else
1044 { bool: false, set: :na }
1045 end
1046 act[:pdf_a5]=if select_arr.inspect \
1047 =~/"--a5"|"--papersize-a5"/ \
1048 or select_arr.inspect \
1049 =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5
1050 { bool: true, set: :on }
1051 else
1052 { bool: false, set: :na }
1053 end
1054 act[:pdf_b5]=if select_arr.inspect \
1055 =~/"--b5"|"--papersize-b5"/ \
1056 or select_arr.inspect \
1057 =~/"--papersize=\S*b5\b\S*"/
1058 { bool: true, set: :on }
1059 else
1060 { bool: false, set: :na }
1061 end
1062 act[:pdf_letter]=if select_arr.inspect \
1063 =~/"--letter"|"--papersize-letter"/ \
1064 or select_arr.inspect \
1065 =~/"--papersize=\S*letter\b\S*"/
1066 { bool: true, set: :on }
1067 else
1068 { bool: false, set: :na }
1069 end
1070 act[:pdf_legal]=if select_arr.inspect \
1071 =~/"--legal"|"--papersize-legal"/ \
1072 or select_arr.inspect \
1073 =~/"--papersize=\S*legal\b\S*"/
1074 { bool: true, set: :on }
1075 else
1076 { bool: false, set: :na }
1077 end
1078 end
1079 act[:epub]=(select_arr.inspect \
1080 =~/"--epub"/) \
1081 ? { bool: true, set: :on }
1082 : { bool: false, set: :na }
1083 act[:odt]=if select_arr.inspect \
1084 =~/"--odt"|"--odf"|"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/
1085 act[:odt_ocn]=if (select_arr.inspect \
1086 =~/"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ \
1087 or select_arr.inspect \
1088 =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/)
1089 { bool: true, set: :on }
1090 elsif select_arr.inspect \
1091 =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/
1092 { bool: false, set: :off }
1093 else
1094 { bool: false, set: :na }
1095 end
1096 { bool: true, set: :on }
1097 else
1098 { bool: false, set: :na }
1099 end
1100 act[:xml_sax]=(select_arr.inspect \
1101 =~/"--xml-sax"|"--sax"/) \
1102 ? { bool: true, set: :on }
1103 : { bool: false, set: :na }
1104 act[:xml_dom]=(select_arr.inspect \
1105 =~/"--xml-dom"|"--dom"/) \
1106 ? { bool: true, set: :on }
1107 : { bool: false, set: :na }
1108 act[:xml_docbook_book]=(select_arr.inspect \
1109 =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \
1110 ? { bool: true, set: :on }
1111 : { bool: false, set: :na }
1112 act[:xml_fictionbook]=(select_arr.inspect \
1113 =~/"--fictionbook"|"--xml-fictionbook"/) \
1114 ? { bool: true, set: :on }
1115 : { bool: false, set: :na }
1116 act[:xml_scaffold_structure_sisu]=select_arr.inspect \
1117 =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \
1118 ? { bool: true, set: :on }
1119 : { bool: false, set: :na }
1120 act[:xml_scaffold_structure_collapse]=select_arr.inspect \
1121 =~/"--xml-scaffold-collapse"/ \
1122 ? { bool: true, set: :on }
1123 : { bool: false, set: :na }
1124 act[:xhtml]=(select_arr.inspect \
1125 =~/"--xhtml"/) \
1126 ? { bool: true, set: :on }
1127 : { bool: false, set: :na }
1128 act[:txt]=if select_arr.inspect \
1129 =~/"--txt"|"--text"|"--plaintext"|"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/
1130 act[:txt_ocn]=if (select_arr.inspect \
1131 =~/"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ \
1132 or select_arr.inspect \
1133 =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/)
1134 { bool: true, set: :on }
1135 elsif select_arr.inspect \
1136 =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/
1137 { bool: false, set: :off }
1138 else
1139 { bool: false, set: :na }
1140 end
1141 { bool: true, set: :on }
1142 else
1143 { bool: false, set: :na }
1144 end
1145 act[:txt_textile]=(select_arr.inspect \
1146 =~/"--textile"/) \
1147 ? { bool: true, set: :on }
1148 : { bool: false, set: :na }
1149 act[:txt_asciidoc]=(select_arr.inspect \
1150 =~/"--asciidoc"/) \
1151 ? { bool: true, set: :on }
1152 : { bool: false, set: :na }
1153 act[:txt_markdown]=(select_arr.inspect \
1154 =~/"--markdown"/) \
1155 ? { bool: true, set: :on }
1156 : { bool: false, set: :na }
1157 act[:txt_rst]=(select_arr.inspect \
1158 =~/"--rst"|"--rest"|"--restructuredtext"/) \
1159 ? { bool: true, set: :on }
1160 : { bool: false, set: :na }
1161 act[:manpage]=(select_arr.inspect \
1162 =~/"--manpage"|"--man"/) \
1163 ? { bool: true, set: :on }
1164 : { bool: false, set: :na }
1165 act[:texinfo]=(select_arr.inspect \
1166 =~/"--texinfo"/) \
1167 ? { bool: true, set: :on }
1168 : { bool: false, set: :na }
1169 act[:psql]=if select_arr.inspect \
1170 =~/"--pg-\S+"/ \
1171 or ((select_arr.inspect =~/"--pg"/) \
1172 && (select_arr.inspect \
1173 =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/))
1174 act[:psql_createdb]=if select_arr.inspect \
1175 =~/"--pg-createdb"|"--createdb"/
1176 { bool: true, set: :on }
1177 else
1178 { bool: false, set: :na }
1179 end
1180 if select_arr.inspect \
1181 =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/
1182 act[:psql_drop]={ bool: true, set: :on }
1183 act[:psql_create]={ bool: true, set: :on }
1184 else
1185 act[:psql_drop]=if select_arr.inspect \
1186 =~/"--pg-dropall"|"--dropall"/
1187 { bool: true, set: :on }
1188 else
1189 { bool: false, set: :na }
1190 end
1191 act[:psql_create]=if select_arr.inspect \
1192 =~/"--pg-create(?:all)?"|"--create(?:all)?"/
1193 { bool: true, set: :on }
1194 else
1195 { bool: false, set: :na }
1196 end
1197 end
1198 act[:psql_import]=if select_arr.inspect \
1199 =~/"--pg-import"|"--import"/
1200 { bool: true, set: :on }
1201 else
1202 { bool: false, set: :na }
1203 end
1204 act[:psql_update]=if select_arr.inspect \
1205 =~/"--pg-update"|"--update"/
1206 act[:psql_remove]={ bool: true, set: :on }
1207 { bool: true, set: :on }
1208 else
1209 act[:psql_remove]=if select_arr.inspect \
1210 =~/"--pg-remove"|"--remove"/
1211 { bool: true, set: :on }
1212 else
1213 { bool: false, set: :na }
1214 end
1215 { bool: false, set: :na }
1216 end
1217 { bool: true, set: :on }
1218 else
1219 act[:psql_createdb]=
1220 { bool: false, set: :na }
1221 act[:psql_drop]=
1222 { bool: false, set: :na }
1223 act[:psql_create]=
1224 { bool: false, set: :na }
1225 act[:psql_import]=
1226 { bool: false, set: :na }
1227 act[:psql_update]=
1228 { bool: false, set: :na }
1229 act[:psql_remove]=
1230 { bool: false, set: :na }
1231 { bool: false, set: :na }
1232 end
1233 act[:sqlite]=if select_arr.inspect \
1234 =~/"--sqlite-\S+"/ \
1235 or (select_arr.inspect \
1236 =~/"--sqlite"/ \
1237 && select_arr.inspect \
1238 =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)
1239 act[:sqlite_createdb]=if select_arr.inspect \
1240 =~/"--sqlite-createdb"|"--createdb"/
1241 { bool: true, set: :on }
1242 else
1243 { bool: false, set: :na }
1244 end
1245 if select_arr.inspect \
1246 =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/
1247 act[:sqlite_drop]={ bool: true, set: :on }
1248 act[:sqlite_create]={ bool: true, set: :on }
1249 else
1250 act[:sqlite_create]=if select_arr.inspect \
1251 =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/
1252 { bool: true, set: :on }
1253 else
1254 { bool: false, set: :na }
1255 end
1256 act[:sqlite_drop]=if select_arr.inspect \
1257 =~/"--sqlite-dropall"|"--dropall"/
1258 { bool: true, set: :on }
1259 else
1260 { bool: false, set: :na }
1261 end
1262 end
1263 act[:sqlite_import]=if select_arr.inspect \
1264 =~/"--sqlite-import"|"--import"/
1265 { bool: true, set: :on }
1266 else
1267 { bool: false, set: :na }
1268 end
1269 act[:sqlite_update]=if select_arr.inspect \
1270 =~/"--sqlite-update"|"--update"/
1271 act[:sqlite_remove]={ bool: true, set: :on }
1272 { bool: true, set: :on }
1273 else
1274 act[:sqlite_remove]=if select_arr.inspect \
1275 =~/"--sqlite-remove"|"--sqlite-remove"/
1276 { bool: true, set: :on }
1277 else
1278 { bool: false, set: :na }
1279 end
1280 { bool: false, set: :na }
1281 end
1282 { bool: true, set: :on }
1283 else
1284 act[:sqlite_createdb]=
1285 { bool: false, set: :na }
1286 act[:sqlite_drop]=
1287 { bool: false, set: :na }
1288 act[:sqlite_create]=
1289 { bool: false, set: :na }
1290 act[:sqlite_import]=
1291 { bool: false, set: :na }
1292 act[:sqlite_update]=
1293 { bool: false, set: :na }
1294 act[:sqlite_remove]=
1295 { bool: false, set: :na }
1296 { bool: false, set: :na }
1297 end
1298 act[:sqlite_discrete]=select_arr.inspect \
1299 =~/"--sql"|"--sqlite"/ \
1300 && (select_arr.inspect \
1301 !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \
1302 ? { bool: true, set: :on }
1303 : { bool: false, set: :na }
1304 act[:harvest]=(select_arr.inspect \
1305 =~/"--harvest"/) \
1306 ? { bool: true, set: :on }
1307 : { bool: false, set: :na }
1308 act[:po4a]=(select_arr.inspect \
1309 =~/"--po4a"|"--pot?"/) \
1310 ? { bool: true, set: :on }
1311 : { bool: false, set: :na }
1312 act[:git]=(select_arr.inspect \
1313 =~/"--git"/) \
1314 ? { bool: true, set: :on }
1315 : { bool: false, set: :na }
1316 act[:hash_digests]=(select_arr.inspect \
1317 =~/"--digests?"|"--hash-digests"/) \
1318 ? { bool: true, set: :on }
1319 : { bool: false, set: :na }
1320 act[:pdf_font_size]=if select_arr.inspect \
1321 =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/
1322 $1
1323 else :na
1324 end
1325 act[:pdf_hyperlink_colors]=if select_arr.inspect \
1326 =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/
1327 :mono
1328 elsif select_arr.inspect \
1329 =~/"--pdf-hyperlinks-color"/
1330 :color
1331 else :na
1332 end
1333 act[:hash_digest_algo]=if select_arr.inspect \
1334 =~/"--hash-(?:sha)?512"/
1335 :sha512
1336 elsif select_arr.inspect \
1337 =~/"--hash-(?:sha)?256"/
1338 :sha256
1339 elsif select_arr.inspect \
1340 =~/"--hash-md5"/
1341 :md5
1342 else :na
1343 end
1344 act[:sample_search_form]=if select_arr.inspect \
1345 =~/"--sample-search-form"/
1346 if select_arr.inspect \
1347 =~/"--db[-=]pg"/
1348 { bool: true, set: :on, db: :pg }
1349 elsif select_arr.inspect \
1350 =~/"--db[-=]sqlite"/
1351 { bool: true, set: :on, db: :sqlite }
1352 else
1353 { bool: true, set: :on, db: :na }
1354 end
1355 else
1356 { bool: false, set: :na, db: :na }
1357 end
1358 act[:webrick]=select_arr.inspect \
1359 =~/"--webrick"/ \
1360 ? { bool: true, set: :on }
1361 : { bool: false, set: :na }
1362 act[:share_source]=select_arr.inspect \
1363 =~/"--source"/ \
1364 ? { bool: true, set: :on }
1365 : { bool: false, set: :na }
1366 act[:sisupod]=select_arr.inspect \
1367 =~/"--sisupod"/ \
1368 ? { bool: true, set: :on }
1369 : { bool: false, set: :na }
1370 act[:scp]=select_arr.inspect \
1371 =~/"--scp"/ \
1372 ? { bool: true, set: :on }
1373 : { bool: false, set: :na }
1374 act[:rsync]=select_arr.inspect \
1375 =~/"--rsync"|"--remote"/ \
1376 ? { bool: true, set: :on }
1377 : { bool: false, set: :na }
1378 act[:zap]=select_arr.inspect \
1379 =~/"--zap"|"--delete"/ \
1380 ? { bool: true, set: :on }
1381 : { bool: false, set: :na }
1382 act[:urls_all]=select_arr.inspect \
1383 =~/"--urls-all"/ \
1384 ? { bool: true, set: :on }
1385 : { bool: false, set: :na }
1386 act[:urls_selected]=if select_arr.inspect \
1387 =~/"--urls"/
1388 { bool: true, set: :on }
1389 elsif select_arr.inspect \
1390 =~/"--harvest/
1391 { bool: false, set: :off }
1392 elsif select_arr.inspect \
1393 =~/"--verbose"|"--maintenance"/
1394 { bool: true, set: :on }
1395 else
1396 { bool: false, set: :na }
1397 end
1398 act[:sitemap]=select_arr.inspect \
1399 =~/"--sitemap"/ \
1400 ? { bool: true, set: :on }
1401 : { bool: false, set: :na }
1402 act[:qrcode]=select_arr.inspect \
1403 =~/"--qrcode"/ \
1404 ? { bool: true, set: :on }
1405 : { bool: false, set: :na }
1406 act[:help]=select_arr.inspect \
1407 =~/"--help/ \
1408 ? { bool: true, set: :on }
1409 : { bool: false, set: :na }
1410 act[:ao]=if select_arr.inspect \
1411 =~/"--ao"|"--dal"/
1412 { bool: true, set: :on }
1413 elsif (act[:txt][:set]==:on \
1414 || act[:txt_textile][:set]==:on \
1415 || act[:txt_asciidoc][:set]==:on \
1416 || act[:txt_markdown][:set]==:on \
1417 || act[:txt_rst][:set]==:on \
1418 || act[:xhtml][:set]==:on \
1419 || act[:epub][:set]==:on \
1420 || act[:html][:set]==:on \
1421 || act[:html_seg][:set]==:on \
1422 || act[:html_scroll][:set]==:on \
1423 || act[:texinfo][:set]==:on \
1424 || act[:manpage][:set]==:on \
1425 || act[:hash_digests][:set]==:on \
1426 || act[:odt][:set]==:on \
1427 || act[:pdf][:set]==:on \
1428 || act[:pdf_p][:set]==:on \
1429 || act[:pdf_l][:set]==:on \
1430 || act[:qrcode][:set]==:on \
1431 || act[:share_source][:set]==:on \
1432 || act[:sisupod][:set]==:on \
1433 || act[:concordance][:set]==:on \
1434 || act[:sqlite_discrete][:set]==:on \
1435 || act[:sqlite_import][:set]==:on \
1436 || act[:sqlite_update][:set]==:on \
1437 || act[:sqlite_remove][:set]==:on \
1438 || act[:psql_import][:set]==:on \
1439 || act[:psql_update][:set]==:on \
1440 || act[:psql_remove][:set]==:on \
1441 || act[:xml_dom][:set]==:on \
1442 || act[:xml_sax][:set]==:on \
1443 || act[:xml_docbook_book][:set]==:on \
1444 || act[:xml_fictionbook][:set]==:on \
1445 || act[:xml_scaffold_structure_sisu][:set]==:on \
1446 || act[:xml_scaffold_structure_collapse][:set]==:on )
1447 { bool: true, set: :on }
1448 else
1449 { bool: false, set: :na }
1450 end
1451 act[:manifest]=if select_arr.inspect \
1452 =~/"--inc-manifest"/
1453 { bool: true, set: :on }
1454 elsif select_arr.inspect \
1455 =~/"--(?:exc|no)-manifest"/ \
1456 || act[:switch][:off].inspect =~/"manifest"/
1457 { bool: false, set: :off }
1458 elsif select_arr.inspect \
1459 =~/"--manifest"/
1460 { bool: true, set: :on }
1461 elsif (act[:txt][:set]==:on \
1462 || act[:txt_textile][:set]==:on \
1463 || act[:txt_asciidoc][:set]==:on \
1464 || act[:txt_markdown][:set]==:on \
1465 || act[:txt_rst][:set]==:on \
1466 || act[:xhtml][:set]==:on \
1467 || act[:epub][:set]==:on \
1468 || act[:html][:set]==:on \
1469 || act[:html_seg][:set]==:on \
1470 || act[:html_scroll][:set]==:on \
1471 || act[:texinfo][:set]==:on \
1472 || act[:manpage][:set]==:on \
1473 || act[:hash_digests][:set]==:on \
1474 || act[:odt][:set]==:on \
1475 || act[:pdf][:set]==:on \
1476 || act[:pdf_p][:set]==:on \
1477 || act[:pdf_l][:set]==:on \
1478 || act[:qrcode][:set]==:on \
1479 || act[:share_source][:set]==:on \
1480 || act[:sisupod][:set]==:on \
1481 || act[:concordance][:set]==:on \
1482 || act[:xml_dom][:set]==:on \
1483 || act[:xml_sax][:set]==:on \
1484 || act[:xml_docbook_book][:set]==:on \
1485 || act[:xml_fictionbook][:set]==:on \
1486 || act[:xml_scaffold_structure_sisu][:set]==:on \
1487 || act[:xml_scaffold_structure_collapse][:set]==:on )
1488 { bool: true, set: :on }
1489 else { bool: true, set: :na }
1490 end
1491 act[:console_messages] = ''
1492 act[:verbose]=if select_arr.inspect \
1493 =~/"--verbose"/
1494 act[:console_messages] << ' --verbose '
1495 { bool: true, set: :on }
1496 else
1497 { bool: false, set: :na }
1498 end
1499 act[:verbose_plus]=if select_arr.inspect \
1500 =~/"--very-verbose"|"--verbose-very"/
1501 act[:console_messages] << ' --very-verbose '
1502 { bool: true, set: :on }
1503 else
1504 { bool: false, set: :na }
1505 end
1506 act[:version_info]=if select_arr.inspect \
1507 =~/"--version"|"--verbose"|"--maintenance"/
1508 act[:console_messages] << ' --maintenance '
1509 { bool: true, set: :on }
1510 else
1511 { bool: false, set: :na }
1512 end
1513 act[:quiet]=if (select_arr.inspect =~/"--quiet"/)
1514 act[:console_messages] << ' --quiet '
1515 { bool: true, set: :on }
1516 else
1517 { bool: false, set: :na }
1518 end
1519 act[:color_state]=if select_arr.inspect =~/"--color-on"|"--color"/
1520 act[:console_messages] << ' --color-on '
1521 { bool: true, set: :on }
1522 elsif (select_arr.inspect =~/"--color-off"/)
1523 act[:console_messages] << ' --color-off '
1524 { bool: false, set: :off }
1525 else { bool: true, set: :na } #fix default color
1526 end
1527 # act[:color_toggle]=if select_arr.inspect =~/"--color-toggle"/
1528 # true
1529 # else false
1530 # end
1531 act[:maintenance]=if (select_arr.inspect =~/"--maintenance|--keep-processing-files"/)
1532 act[:console_messages] << ' --maintenance '
1533 { bool: true, set: :on }
1534 else
1535 { bool: false, set: :na }
1536 end
1537 act[:profile]=if (select_arr.inspect =~/"--profile"/)
1538 act[:console_messages] << ' --color-off '
1539 { bool: true, set: :on }
1540 else
1541 { bool: false, set: :na }
1542 end
1543 @act=act
1544 end
1545 end
1546 def opt_ch
1547 @opt_ch
1548 end
1549 def selections
1550 def arr
1551 @select_arr.sort
1552 end
1553 def str
1554 @select_str ||= arr.join(' ')
1555 end
1556 self
1557 end
1558 def act
1559 @@act
1560 end
1561 def files_mod
1562 files_mod=files
1563 @files_mod=files_mod
1564 end
1565 def files
1566 @files
1567 end
1568 def f_pth
1569 @f_pth
1570 end
1571 def pth
1572 @pth
1573 end
1574 def sub_location
1575 pth.gsub(/#{base_path}/,'')
1576 end
1577 def lng
1578 @lng
1579 end
1580 def lng_base
1581 @lng_base
1582 end
1583 def fno
1584 @fno=(fns.nil? || fns.empty?) \
1585 ? '' \
1586 : (fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1])
1587 end
1588 def fng
1589 @fng=(fno.nil? || fno.empty?) \
1590 ? '' \
1591 : (fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1'))
1592 end
1593 def fns
1594 @fns
1595 end
1596 def fnl
1597 @fns.gsub(/(\S+?)((?:\.ssm)?\.sst)/,"\\1.#{lng}\\2")
1598 end
1599 def what
1600 @what
1601 end
1602 def fnb
1603 (fns.nil? || fns.empty?) \
1604 ? '' \
1605 : (fns[/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/,1])
1606 end
1607 def fnc
1608 @fnc=(@fns =~/\.(?:ssm\.sst|ssm)$/) \
1609 ? fnb + '.ssm.sst'
1610 : @fns
1611 end
1612 def fncb
1613 @fncb=(@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/) \
1614 ? fnb + '.ssm.sst'
1615 : @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1')
1616 end
1617 end
1618 end
1619 __END__
1620 note usually named @opt is carried in dp document parameters (usually as @md.opt), @opt is a
1621 subset of @md where @md is passed, contents of @opt are available as @md.opt
1622 passing @opt as well is duplication check for fns & fnb