Class: Fontist::ImportCLI
Instance Method Summary
collapse
#handle_class_options, included, #log_level
Instance Method Details
#google ⇒ Object
29
30
31
32
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
58
59
60
61
62
|
# File 'lib/fontist/import_cli.rb', line 29
def google
handle_class_options(options)
font_name = options[:font_name] || options[:font_family]
importer = Fontist::Import::GoogleFontsImporter.new(
source_path: options[:source_path],
output_path: options[:output_path],
font_family: font_name,
force: options[:force],
verbose: options[:verbose],
import_cache: options[:import_cache],
schema_version: options[:schema_version],
)
result = importer.import
unless options[:verbose]
Fontist.ui.success("Import completed")
Fontist.ui.say(" Successful: #{result[:successful]}")
Fontist.ui.say(" Skipped: #{result[:skipped]}") if result[:skipped]&.positive?
Fontist.ui.say(" Overwritten: #{result[:overwritten]}") if result[:overwritten]&.positive?
Fontist.ui.say(" Failed: #{result[:failed]}") if result[:failed]&.positive?
Fontist.ui.say(" Duration: #{format_duration(result[:duration])}")
end
CLI::STATUS_SUCCESS
rescue StandardError => e
Fontist.ui.error("Import error: #{e.message}")
Fontist.ui.error(e.backtrace.join("\n")) if options[:verbose]
Fontist::CLI::STATUS_UNKNOWN_ERROR
end
|
#macos ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/fontist/import_cli.rb', line 91
def macos
handle_class_options(options)
require_relative "import/macos_importer"
output_dir = if options[:formulas_dir] && !options[:output_path]
Fontist.ui.error("DEPRECATED: --formulas-dir is deprecated, use --output-path instead")
options[:formulas_dir]
else
options[:output_path]
end
plist_path = options[:plist] || detect_latest_catalog
force = options[:force]
verbose = options[:verbose]
font_name = options[:font_name]
Import::MacosImporter.new(
plist_path,
formulas_dir: output_dir,
font_name: font_name,
force: force,
verbose: verbose,
import_cache: options[:import_cache],
schema_version: options[:schema_version],
).call
CLI::STATUS_SUCCESS
rescue StandardError => e
Fontist.ui.error("Import error: #{e.message}")
Fontist.ui.error(e.backtrace.join("\n")) if options[:verbose]
CLI::STATUS_UNKNOWN_ERROR
end
|
#sil ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/fontist/import_cli.rb', line 146
def sil
handle_class_options(options)
require "fontist/import/sil_importer"
importer = Fontist::Import::SilImporter.new(
output_path: options[:output_path],
font_name: options[:font_name],
force: options[:force],
verbose: options[:verbose],
import_cache: options[:import_cache],
schema_version: options[:schema_version],
)
result = importer.call
unless options[:verbose]
Fontist.ui.success("Import completed")
Fontist.ui.say(" Successful: #{result[:successful]}")
Fontist.ui.say(" Skipped: #{result[:skipped]}") if result[:skipped]&.positive?
Fontist.ui.say(" Overwritten: #{result[:overwritten]}") if result[:overwritten]&.positive?
Fontist.ui.say(" Failed: #{result[:failed]}") if result[:failed]&.positive?
Fontist.ui.say(" Duration: #{format_duration(result[:duration])}")
end
CLI::STATUS_SUCCESS
rescue StandardError => e
Fontist.ui.error("Import error: #{e.message}")
Fontist.ui.error(e.backtrace.join("\n")) if options[:verbose]
Fontist::CLI::STATUS_UNKNOWN_ERROR
end
|