Class: Fontist::ManifestCLI

Inherits:
Thor
  • Object
show all
Includes:
CLI::ClassOptions
Defined in:
lib/fontist/manifest_cli.rb

Instance Method Summary collapse

Methods included from CLI::ClassOptions

#handle_class_options, included, #log_level

Instance Method Details

#install(manifest) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fontist/manifest_cli.rb', line 16

def install(manifest)
  handle_class_options(options)
  instance = Fontist::Manifest.from_file(manifest)
  paths = instance.install(
    confirmation: options[:accept_all_licenses] ? "yes" : "no",
    hide_licenses: options[:hide_licenses],
    location: options[:location]&.to_sym,
  )
  print_yaml(paths.to_hash)
  CLI::STATUS_SUCCESS
rescue Fontist::Errors::GeneralError => e
  handle_error(e)
end

#locations(manifest) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fontist/manifest_cli.rb', line 33

def locations(manifest)
  handle_class_options(options)

  start_time = Time.now

  paths = Fontist::Manifest.from_file(manifest, locations: true)

  resolve_time = Time.now - start_time

  print_yaml(paths.to_hash)

  if options[:show_timing]
    puts
    puts Paint["⏱ Timing:", :cyan, :bright]
    puts Paint["  Manifest resolution time: ",
               :white] + Paint["#{resolve_time.round(3)}s", :yellow,
                               :bright]
    puts Paint["  Fonts in manifest:         ",
               :white] + Paint[paths.fonts.size.to_s, :yellow]
  end

  CLI::STATUS_SUCCESS
rescue Fontist::Errors::GeneralError => e
  handle_error(e)
end