Class: Ucode::Cli

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

Overview

Top-level CLI entry.

**Thin Thor**: every method delegates to a ‘Commands::*Command` class and only formats the result. The Command classes are pure and testable in-process — Thor never holds business logic.

Defined Under Namespace

Classes: Cache, Fetch, Lookup, Site

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ucode/cli.rb', line 16

def self.exit_on_failure?
  true
end

Instance Method Details

#build(version = nil) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/ucode/cli.rb', line 212

def build(version = nil)
  result = Commands::BuildCommand.new.call(
    version,
    output_root: options[:to],
    site_root: options[:site],
    monolith_path: options[:monolith],
    force_fetch: options[:force_fetch],
    include_glyphs: options[:include_glyphs],
    warn: $stderr,
  )
  puts JSON.pretty_generate(result)
end

#font_coverage(*fonts) ⇒ Object

Raises:

  • (Thor::Error)


244
245
246
247
248
249
250
251
252
253
# File 'lib/ucode/cli.rb', line 244

def font_coverage(*fonts)
  raise Thor::Error, "Provide at least one font" if fonts.empty?

  results = Commands::FontCoverageCommand.new.call(
    fonts,
    output_root: options[:to],
    install: !options[:no_install],
  )
  puts JSON.pretty_generate(results.map { |r| result_to_h(r) })
end

#glyphs(version = nil) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ucode/cli.rb', line 89

def glyphs(version = nil)
  result = Commands::GlyphsCommand.new.call(
    version,
    output_root: options[:to],
    block_filter: options[:block],
    force: options[:force],
    monolith_path: options[:monolith],
    include_glyphs: options[:include_glyphs],
    warn: $stderr,
  )
  puts JSON.pretty_generate(result)
end

#parse(version = nil) ⇒ Object



69
70
71
72
# File 'lib/ucode/cli.rb', line 69

def parse(version = nil)
  result = Commands::ParseCommand.new.call(version, output_root: options[:to])
  puts JSON.pretty_generate(result)
end

#versionObject



22
23
24
# File 'lib/ucode/cli.rb', line 22

def version
  puts "ucode #{Ucode::VERSION}"
end