diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-12-28 12:25:17 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-12-28 12:25:17 -0500 |
commit | a4e463e111ba498197315b8c6e5d882eb73be4a8 (patch) | |
tree | 893b67400a7fd540d1b15984d75bda50e8ec34bc /lib/sisu/v4 | |
parent | v4 v3: debug (internal code use), color markers for line number & file name (diff) |
v4: sisu: --color flag, which toggles color on/off (Closes: #622171)
* the fix here is specific to color on/off for reporting of sisu version
* sisu --version --color-off || sisu -v -k || sisu -kv
* there are various ways to control color output to screen
* --color-off or -k switches color off
* --color or --color-on switches color on, which is usually the default
* --color-toggle or -c toggles the default setting (in most cases)
* sisurc.yml can set default color state which affects most screen output
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r-- | lib/sisu/v4/help.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v4/hub.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v4/options.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v4/screen_text_color.rb | 8 |
4 files changed, 17 insertions, 14 deletions
diff --git a/lib/sisu/v4/help.rb b/lib/sisu/v4/help.rb index 391e722d..23afd512 100644 --- a/lib/sisu/v4/help.rb +++ b/lib/sisu/v4/help.rb @@ -63,7 +63,8 @@ module SiSU_Help require_relative 'i18n' # i18n.rb def initialize(request='',color='') @request,@color=request,color - @cX=(color =~/color_off/) \ + @cX=((color =~/color_off/) \ + || (defined? color.act && color.act[:color_state][:set]==:off)) \ ? (SiSU_Screen::Ansi.new('k').cX) : (SiSU_Screen::Ansi.new('yes').cX) fns='help_example_dummy_file_name.sst' @@ -900,7 +901,12 @@ If you have problems check permissions (and if in home directory ownership). version=SiSU_Env::InfoVersion.instance.get_version rb_ver=SiSU_Env::InfoVersion.instance.rbversion if version[:version] - SiSU_Screen::Ansi.new('-v',version[:project],version[:version],version[:date_stamp],version[:date],rb_ver).version + opt_cmd=if defined? @color.cmd \ + and @color.cmd =~/[ck]/ + @color.cmd + else '-v' + end + SiSU_Screen::Ansi.new(opt_cmd,version[:project],version[:version],version[:date_stamp],version[:date],rb_ver).version else puts 'SiSU version information not available' end end diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index da5b785e..1fb73a73 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -440,12 +440,6 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on end SiSU::Operations.new.counter end - if @opt.cmd =~/k/ #% -k temporary tests - OptionLoopFiles.new(@opt).loop_files_on_given_option do - #require_relative 'xml_scaffold' - #fix - end - end if @opt.act[:psql][:set]==:on #% --pg, -D DB postgresql require_relative 'dbi' if @opt.files.length > 0 #switch test to actual commands diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index b26bada2..9b9e1249 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -260,7 +260,7 @@ module SiSU_Commandline @cmd=shortcut.cf_0 + 'm' end if @cmd =~/[vVM]/ \ - && @cmd !~/-vu?$/ + && @cmd !~/-[ku]*v[ku]*$/ SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown end end @@ -466,6 +466,7 @@ module SiSU_Commandline m.each do |m| case m when /^--(?:color-toggle)$/; c=c+'c' + when /^--(?:color-off)$/; c=c+'k' when /^--(?:configure|init-site)$/; c=c+'CC' when /^--(?:dal?|machine|abstraction|abs)$/; c=c+'m' when /^--(?:txt|text|plaintext)$/; c=c+'t' @@ -501,6 +502,7 @@ module SiSU_Commandline when /^--(?:verbose[=-]3)$/; c=c+'VM' when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/; c=c+'V' when /^--(?:verbose(?:[=-]1)?)$/; c=c+'v' + when /^--(?:version)$/; c=c+'v' when /^--(?:verbose[=-]0|quiet|silent)$/; c=c+'q' else mod << m #mod only contains command modifiers; commands converted to character end @@ -609,7 +611,8 @@ module SiSU_Commandline : { bool: false, set: :na } act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ { bool: true, set: :on } - elsif mod.inspect =~/"--color-off"/ + elsif (cmd =~/k/ \ + || mod.inspect =~/"--color-off"/) { bool: false, set: :off } else { bool: true, set: :na } #fix default color end diff --git a/lib/sisu/v4/screen_text_color.rb b/lib/sisu/v4/screen_text_color.rb index a9c0b367..1a4f87b9 100644 --- a/lib/sisu/v4/screen_text_color.rb +++ b/lib/sisu/v4/screen_text_color.rb @@ -68,12 +68,12 @@ module SiSU_Screen @cmd,@txt=cmd,txt @color_instruct=txt[0] flag=SiSU_Env::InfoProcessingFlag.new - if @cmd + if cmd #set default colors on or off -c acts as toggle against this default, if default is off -c turns on, if default is on -c turns off @use_color=(flag.color) \ - ? ((@cmd =~/c/) ? false : true) - : ((@cmd =~/c/) ? true : false) - if @cmd =~/k/ then @use_color=false # useful color off switch, however, k may be used for something else in future + ? ((cmd =~/c/) ? false : true) + : ((cmd =~/c/) ? true : false) + if cmd =~/k/ then @use_color=false # useful color off switch, however, k may be used for something else in future end else @use_color=false end |