Class: Spriteful::CLI

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/spriteful/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Public: Initializes the CLI object and replaces the frozen ‘options’ object with an unfrozen one that we can mutate.



39
40
41
42
# File 'lib/spriteful/cli.rb', line 39

def initialize(*)
  super
  self.options = options.dup
end

Class Method Details

Public: Gets the CLI banner for the Thor help message.

Returns a String.



33
34
35
# File 'lib/spriteful/cli.rb', line 33

def self.banner
  'spriteful sources [options]'
end

Instance Method Details

#executeObject

Public: executes the CLI processing of the sprite sources into combined images and stylesheets. Returns nothing.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/spriteful/cli.rb', line 47

def execute
  if options.version?
    say "Spriteful #{Spriteful::VERSION}"
    exit(0)
  end

  prepare_options!

  if sources.empty?
    self.class.help(shell)
    exit(1)
  end

  sources.uniq!
  sources.each do |source|
    create_sprite(source)
  end

  save_options
end

#templateObject



68
69
70
# File 'lib/spriteful/cli.rb', line 68

def template
  create_file "spriteful.#{options.format}", Spriteful::Stylesheet.read_template(options.format)
end