Class: Fontcustom::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject

Required for Thor::Actions#template



54
55
56
# File 'lib/fontcustom/cli.rb', line 54

def self.source_root
  File.join Fontcustom.gem_lib, "templates"
end

Instance Method Details

#compile(input = nil) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/fontcustom/cli.rb', line 59

def compile(input = nil)
  opts = options.merge :input => input
  opts = Options.new(opts)
  Generator::Font.start [opts]
  Generator::Template.start [opts]
rescue Fontcustom::Error => e
  opts.say_message :error, e.message, :red
end

#config(dir = Dir.pwd) ⇒ Object



82
83
84
# File 'lib/fontcustom/cli.rb', line 82

def config(dir = Dir.pwd)
  template "fontcustom.yml", File.join(dir, "fontcustom.yml")
end

#show_helpObject



88
89
90
91
92
93
94
# File 'lib/fontcustom/cli.rb', line 88

def show_help
  if options[:version]
    puts "fontcustom-#{VERSION}"
  else
    help
  end
end

#watch(input = nil) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/fontcustom/cli.rb', line 72

def watch(input = nil)
  say "Font Custom is watching your icons. Press Ctrl + C to stop.", :yellow unless options[:quiet]
  opts = options.merge :input => input, :skip_first => !! options[:skip_first]
  opts = Options.new(opts)
  Watcher.new(opts).watch
rescue Fontcustom::Error => e
  opts.say_message :error, e.message, :red
end