aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/param.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-10-23 23:40:45 -0400
committerRalph Amissah <ralph@amissah.com>2013-10-23 23:40:45 -0400
commitedd89902036bde18c91031470e19c871a182cf6d (patch)
tree1269e7b1660aa64896fc21768002e837233c2c24 /lib/sisu/v5/param.rb
parentv4 v5: version & changelog (diff)
v5: options & downstream, more use of opt.act instead of opt.cmd
* opt.act.*.set==:on instead of opt.cmd =~/\S/
Diffstat (limited to 'lib/sisu/v5/param.rb')
-rw-r--r--lib/sisu/v5/param.rb41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb
index 0720f943..e8144a5e 100644
--- a/lib/sisu/v5/param.rb
+++ b/lib/sisu/v5/param.rb
@@ -78,7 +78,7 @@ module SiSU_Param
@@md=@@fns=@@pth=nil
def initialize(opt)
@opt=opt
- @cX||=SiSU_Screen::Ansi.new(opt.cmd)
+ @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set])
@cmd,@mod=opt.cmd,opt.mod
@fns=if @opt.cmd =~/P/ #revisit CHECK
opt.fns
@@ -105,7 +105,7 @@ module SiSU_Param
@@md=nil
end
if @@md.nil? \
- or @opt.cmd =~/M/ #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file
+ or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file
if File.exist?(@pstorefile)
param_msg='Parameters from pstore'
store=PStore.new(@pstorefile)
@@ -120,7 +120,11 @@ module SiSU_Param
@md
end
if defined? @md.title.main # on removal check problems with -U
- SiSU_Screen::Ansi.new(@opt.cmd,param_msg,@md.title.main).txt_grey if @opt.cmd =~/[MVv]/
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],param_msg,@md.title.main).txt_grey
+ end
end
@@md=@md
else @@md
@@ -178,7 +182,7 @@ module SiSU_Param
STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}"
s
else
- SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.cmd =~/q/
+ SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on
nil
end
end
@@ -499,7 +503,7 @@ module SiSU_Param
elsif @h['main']
@h['main']
else
- SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on
''
end
l,n=Db[:col_info_note],'rights.copyright.text'
@@ -598,7 +602,7 @@ module SiSU_Param
s +='\\\\ License: ' + copyright.license
end
if s.empty?
- SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on
else
l,n=Db[:col_info_note],'rights.all'
validate_length(s,l,n)
@@ -894,7 +898,10 @@ module SiSU_Param
@prog=SiSU_Env::InfoSettings.new
@sys=SiSU_Env::SystemCall.new
@env=SiSU_Env::InfoEnv.new(@fns) #watch
- puts 'system locale: ' + @sys.locale if @opt.cmd =~/[MV]/
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ puts 'system locale: ' + @sys.locale
+ end
if @prog.wc \
and @sys.wc
wc=%x{wc #{fns}}
@@ -1104,7 +1111,7 @@ module SiSU_Param
? " #{@creator.author}"
: ''
title=%{"#{@title.full.gsub(/(<p>|<p \/>|<br>|<br \/>)/,'')}",}
- SiSU_Screen::Ansi.new(@opt.cmd,'Parameters',%{#{title}#{creator}}).txt_grey if @opt.cmd =~/v/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Parameters',%{#{title}#{creator}}).txt_grey if @opt.act[:verbose][:set]==:on
end
if not @book_idx \
and para =~/^=\{(.+?)\}\s*$/
@@ -1163,8 +1170,9 @@ module SiSU_Param
end
end #% here endeth the document loop
unless @make
- if @opt.cmd =~/[VM]/
- SiSU_Screen::Ansi.new(@opt.cmd,'@make:','header absent').warn
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'@make:','header absent').warn
end
@make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make
end
@@ -1295,13 +1303,13 @@ module SiSU_Param
if @en[:note] > 0 \
and @en[:sum] > 0
if @en[:sum] > 0
- else SiSU_Screen::Ansi.new(@opt.cmd,'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn if @opt.cmd !~/q/
+ else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:unless][:set]==:on
end
end
if @en[:mark] != @en[:note] \
and @en[:note] > 0
@en[:mismatch]=@en[:note] - @en[:mark]
- SiSU_Screen::Ansi.new(@opt.cmd,'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn if @opt.cmd !~/q/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn unless @opt.act[:quiet][:set]==:on
footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a')
footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n"
end
@@ -1312,7 +1320,7 @@ module SiSU_Param
and @opt.inspect =~/P/
#@title=Md.new('Text Insert',@opt,@env).title
else
- SiSU_Screen::Ansi.new(@opt.cmd,'WARNING: Document Title missing','please provide @title:').warn unless @opt.cmd =~/q/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:unless][:set]==:on
end
end
if @author !~/[\S]/
@@ -1320,7 +1328,7 @@ module SiSU_Param
and @opt.inspect =~/P/
#@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator
else
- SiSU_Screen::Ansi.new(@opt.cmd,'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.cmd =~/q/
+ SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:unless][:set]==:on
end
end
@struct={}
@@ -1400,7 +1408,10 @@ module SiSU_Param
begin
pstorefile="#{@env.processing_path.dal}/#{@md.fns}.pstore"
File.unlink(pstorefile) if FileTest.file?(pstorefile)
- SiSU_Screen::Ansi.new(@md.opt.cmd,"PStore -> #{pstorefile}").txt_grey if @md.opt.cmd =~/[MV]/
+ if (@md.opt.act[:verbose_plus][:set]==:on \
+ || @md.opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"PStore -> #{pstorefile}").txt_grey
+ end
store=PStore.new(pstorefile)
store.transaction do
store['md']=@md