Class: Fontisan::Commands::ExportCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Fontisan::Commands::ExportCommand
- Defined in:
- lib/fontisan/commands/export_command.rb
Overview
ExportCommand provides CLI interface for font export to YAML/JSON
This command exports fonts to TTX-like YAML/JSON formats for debugging and font analysis. Supports selective table export and both formats.
Instance Method Summary collapse
-
#initialize(input:, output: nil, format: :yaml, tables: nil, binary_format: :hex, pretty: true) ⇒ ExportCommand
constructor
Initialize export command.
-
#run ⇒ Integer
Run the export command.
Constructor Details
#initialize(input:, output: nil, format: :yaml, tables: nil, binary_format: :hex, pretty: true) ⇒ ExportCommand
Initialize export command
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fontisan/commands/export_command.rb', line 33 def initialize(input:, output: nil, format: :yaml, tables: nil, binary_format: :hex, pretty: true) super() @input = input @output = output @format = format.to_sym @tables = tables @binary_format = binary_format.to_sym @pretty = pretty end |
Instance Method Details
#run ⇒ Integer
Run the export command
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fontisan/commands/export_command.rb', line 47 def run validate_params! # Load font font = load_font return 1 unless font # Create exporter exporter = Export::Exporter.new( font, @input, binary_format: @binary_format, ) # Export to model export_model = exporter.export( tables: @tables || :all, format: @format, ) # Output result output_export(export_model) 0 rescue StandardError => e puts "Error: #{e.}" puts e.backtrace.join("\n") if ENV["DEBUG"] 1 end |