Class: TNS::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/tns/cli.rb

Overview

CLI to generate stuff

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/tns/cli.rb', line 49

def self.exit_on_failure?
  true
end

Instance Method Details

#generate(color) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tns/cli.rb', line 34

def generate(color)
  rgb = Color::RGB.from_hex(color)
  name = options["name"]
  color_format = options["color-format"]
  output = options["output"]
  palette = Palette.new(rgb).to(color_format)
  output = Output.from_argument(output, name)
  puts output.format(palette)
rescue ArgumentError => e
  # Wrap argument errors into thor errors for nicer reporting to user
  raise Thor::Error, e.message
end