Class: Foxtail::CLI::Commands::Ids

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/foxtail/cli/commands/ids.rb

Overview

Extract message and term IDs from FTL files

Instance Method Summary collapse

Instance Method Details

#call(files:, only_messages:, only_terms:, with_attributes:, json:) ⇒ void

This method returns an undefined value.

Execute the ids command

Parameters:

  • files (Array<String>)

    FTL files to extract IDs from

  • only_messages (Boolean)

    Show only message IDs

  • only_terms (Boolean)

    Show only term IDs

  • with_attributes (Boolean)

    Include attribute names

  • json (Boolean)

    Output as JSON array

Raises:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/foxtail/cli/commands/ids.rb', line 27

def call(files:, only_messages:, only_terms:, with_attributes:, json:, **)
  raise Foxtail::CLI::NoFilesError if files.empty?

  ids = []

  files.each do |file|
    ids.concat(extract_ids(file, only_messages:, only_terms:, with_attributes:))
  end

  if json
    out.puts JSON.pretty_generate(ids)
  else
    ids.each {|id| out.puts id }
  end
end