mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-07 07:31:12 +08:00
Fix color command option
This commit is contained in:
parent
7fc7c797af
commit
2181e4a0f7
@ -31,7 +31,7 @@ module Uplot
|
|||||||
@debug = parser.debug
|
@debug = parser.debug
|
||||||
|
|
||||||
if command == :colors
|
if command == :colors
|
||||||
Plot.colors
|
Plot.colors(parser.color_names)
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,19 +7,21 @@ module Uplot
|
|||||||
class Command
|
class Command
|
||||||
class Parser
|
class Parser
|
||||||
attr_reader :command, :params,
|
attr_reader :command, :params,
|
||||||
:delimiter, :transpose, :headers, :pass, :output, :fmt, :debug
|
:delimiter, :transpose, :headers, :pass, :output, :fmt,
|
||||||
|
:color_names, :debug
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@command = nil
|
@command = nil
|
||||||
@params = Params.new
|
@params = Params.new
|
||||||
|
|
||||||
@delimiter = "\t"
|
@delimiter = "\t"
|
||||||
@transpose = false
|
@transpose = false
|
||||||
@headers = nil
|
@headers = nil
|
||||||
@pass = false
|
@pass = false
|
||||||
@output = $stderr
|
@output = $stderr
|
||||||
@fmt = 'xyy'
|
@fmt = 'xyy'
|
||||||
@debug = false
|
@debug = false
|
||||||
|
@color_names = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_default_parser
|
def create_default_parser
|
||||||
@ -202,7 +204,7 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
when :colors
|
when :colors
|
||||||
parser.on_head('-n', '--names', TrueClass) do |v|
|
parser.on_head('-n', '--names', 'show color names only', TrueClass) do |v|
|
||||||
@color_names = v
|
@color_names = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_method2(method1)
|
def get_method2(method1)
|
||||||
(method1.to_s + '!').to_sym
|
"#{method1}!".to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def plot_xyy(data, method1, params)
|
def plot_xyy(data, method1, params)
|
||||||
@ -121,12 +121,14 @@ module Uplot
|
|||||||
UnicodePlot.boxplot(headers, series, **params.to_hc)
|
UnicodePlot.boxplot(headers, series, **params.to_hc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def colors
|
def colors(color_names = false)
|
||||||
UnicodePlot::StyledPrinter::TEXT_COLORS.each do |k, v|
|
UnicodePlot::StyledPrinter::TEXT_COLORS.each do |k, v|
|
||||||
print v
|
print v
|
||||||
print k
|
print k
|
||||||
print "\t"
|
unless color_names
|
||||||
print ' ●'
|
print "\t"
|
||||||
|
print ' ●'
|
||||||
|
end
|
||||||
print "\033[0m"
|
print "\033[0m"
|
||||||
print "\t"
|
print "\t"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user