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
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fontisan/commands/export_command.rb', line 37 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
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 76 77 78 79 |
# File 'lib/fontisan/commands/export_command.rb', line 51 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 |