Class: AnyStyle::CLI::Commands::Parse

Inherits:
Base
  • Object
show all
Defined in:
lib/anystyle/cli/commands/parse.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #output_folder

Instance Method Summary collapse

Methods inherited from Base

#each_format, #extsub, #find, #format, #initialize, #overwrite?, #parse, #report, #say, #set_output_folder, #stdout?, #transpose, #verbose?, #walk, #write

Constructor Details

This class inherits a constructor from AnyStyle::CLI::Commands::Base

Instance Method Details

#run(args, params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/anystyle/cli/commands/parse.rb', line 5

def run(args, params)
  set_output_folder args[1]
  walk args[0] do |path, base_path|
    say "Parsing #{path.relative_path_from(base_path)} ..."
    dataset = parse(path.to_s.untaint)
    say "#{dataset.length} references found."
    each_format do |fmt|
      res = format(dataset, fmt)
      out = extsub(path, ".#{fmt}")
      say "Writing #{out.relative_path_from(base_path)} ..."
      write res, out, base_path
    end
  end
end