Skip to content

Commit

Permalink
Show a error message when linecolor is specified as a number
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Jul 2, 2021
1 parent 7c00f95 commit aa13ecc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/youplot/backends/unicode_plot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@
require_relative 'processing'
require 'unicode_plot'

module UnicodePlot
class << self
alias lineplot_original lineplot
def lineplot(*args, **kw)
if kw[:color].is_a? Numeric
warn <<~EOS
YouPlot: Line colors cannot be specified by numerical values.
For more information, please see the following issue.
https://github.com/red-data-tools/unicode_plot.rb/issues/34
EOS
# NOTE: Error messages cannot be colored.
YouPlot.run_as_executable ? exit(1) : raise(Error)
else
lineplot_original(*args, **kw)
end
end
end
end

module YouPlot
# plotting functions.
module Backends
Expand Down Expand Up @@ -182,7 +202,7 @@ def check_series_size(data, fmt)
series = data.series
if series.size == 1
warn <<~EOS
youplot: There is only one series of input data. Please check the delimiter.
YouPlot: There is only one series of input data. Please check the delimiter.
Headers: \e[35m#{data.headers.inspect}\e[0m
The first item is: \e[35m\"#{series[0][0]}\"\e[0m
Expand Down

0 comments on commit aa13ecc

Please sign in to comment.