Sha256: 5cb92f55f9b7e2d2545d487c796bf389a8ebf5f42caf4adcd2ac34c0a6ffe24a
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true # typed: true require "sorbet_progress/error" require "sorbet_progress/metrics" require "sorbet_progress/parser" module SorbetProgress # Parses the provided metrics file and prints a report. class CLI extend T::Sig USAGE = <<~EOS Usage: sorbet_progress /path/to/sorbet_metrics.json EOS sig { params(argv: T::Array[String]).void } def initialize(argv) unless argv.length == 1 raise Error.new(1, USAGE) end @path = argv.first end sig { void } def run metrics = parse(@path) puts "SorbetProgress:" { total_signatures: "ruby_typer.unknown..types.sig.count", total_methods: "ruby_typer.unknown..types.input.methods.total", total_classes: "ruby_typer.unknown..types.input.classes.total", sigil_ignore: "ruby_typer.unknown..types.input.files.sigil.ignore", sigil_false: "ruby_typer.unknown..types.input.files.sigil.false", sigil_true: "ruby_typer.unknown..types.input.files.sigil.true", sigil_strong: "ruby_typer.unknown..types.input.files.sigil.strong" }.each do |label, name| metric = metrics[name] if metric.nil? print_metric_not_found(label) else print_metric(label, metric.value) end end puts "Keep up the good work 👍" end private sig { params(path: String).returns(Metrics) } def parse(path) Parser.new.parse(File.read(path)) rescue Errno::ENOENT => e raise Error.new(2, "Metrics file not found: " + e.message) end def print_metric(label, value) puts format("%-17s\t%d", label, value) end def print_metric_not_found(label) puts format("%-17s\tunknown", label) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sorbet-progress-0.2.2 | lib/sorbet_progress/cli.rb |
sorbet-progress-0.2.1 | lib/sorbet_progress/cli.rb |
sorbet-progress-0.2.0 | lib/sorbet_progress/cli.rb |