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



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

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

Instance Method Details

#compile(input = nil) ⇒ Object



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

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]
end

#config(dir = Dir.pwd) ⇒ Object



93
94
95
# File 'lib/fontcustom/cli.rb', line 93

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

#show_helpObject



99
100
101
102
103
104
105
# File 'lib/fontcustom/cli.rb', line 99

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

#watch(input = nil) ⇒ Object



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

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
end