Class: Fontcustom::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utility

#behavior, #destination_root, #line_break, #methodize_hash, #options, #project_root, #say_changed, #say_message, #say_status, #shell, shell, #source_paths, #symbolize_hash, #write_file

Class Method Details

.source_rootObject

Required for Thor::Actions#template



77
78
79
# File 'lib/fontcustom/cli.rb', line 77

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

Instance Method Details

#compile(input = nil) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/fontcustom/cli.rb', line 82

def compile(input = nil)
  Base.new(options.merge(:input => input)).compile
rescue Fontcustom::Error => e
  say_status :error, e.message, :red
  puts e.backtrace.join("\n") if options[:debug]
  exit 1
end

#config(dir = Dir.pwd) ⇒ Object



104
105
106
# File 'lib/fontcustom/cli.rb', line 104

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

#show_helpObject



110
111
112
113
114
115
116
# File 'lib/fontcustom/cli.rb', line 110

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

#watch(input = nil) ⇒ Object



94
95
96
97
98
99
100
101
# File 'lib/fontcustom/cli.rb', line 94

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]
  Watcher.new(opts).watch
rescue Fontcustom::Error => e
  say_status :error, e.message, :red
  exit 1
end