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.

Version resolution lives here — each top-level command resolves the user-supplied intent (nil / :default / :latest / explicit string) exactly once via VersionResolver.resolve and threads the resolved string into the dispatched Command. Sub-commands never re-resolve. See Candidate 4 of the 2026-06-29 architecture review.

Defined Under Namespace

Classes: Audit, Cache, CodeChartCmd, Fetch, Lookup, Site, UniversalSetCmd

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ucode/cli.rb', line 24

def self.exit_on_failure?
  true
end

Instance Method Details

#block_feedObject



677
678
679
680
681
682
683
684
# File 'lib/ucode/cli.rb', line 677

def block_feed
  result = Commands::BlockFeedCommand.new.call(
    ucode_output_root: options[:ucode_output],
    block_feed_output_root: options[:target],
    unicode_version: options[:unicode_version],
  )
  puts JSON.pretty_generate(result.to_h)
end

#build(version = nil) ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/ucode/cli.rb', line 353

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

#glyphs(version = nil) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ucode/cli.rb', line 127

def glyphs(version = nil)
  result = Commands::GlyphsCommand.new.call(
    VersionResolver.resolve(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



105
106
107
108
109
110
# File 'lib/ucode/cli.rb', line 105

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

#releaseObject



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'lib/ucode/cli.rb', line 638

def release
  reference = Ucode::Audit::ReferenceFactory.build_from_cli(
    flag: options[:reference_universal_set],
    version: options[:unicode_version],
  )
  result = Commands::ReleaseCommand.new.call(
    from: options[:from],
    output_root: options[:output],
    universal_set_root: options[:universal_set],
    unicode_version: options[:unicode_version],
    brief: options[:brief],
    browse: options[:browse],
    source_config_sha256: options[:source_config_sha256],
    reference: reference,
  )
  puts JSON.pretty_generate(result_to_h(result))
end

#versionObject



30
31
32
# File 'lib/ucode/cli.rb', line 30

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