Class: AnyStyle::CLI::Commands::Find
- Defined in:
- lib/anystyle/cli/commands/find.rb
Instance Attribute Summary
Attributes inherited from Base
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 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/anystyle/cli/commands/find.rb', line 5 def run(args, params) set_output_folder args[1] walk args[0] do |path, base_path| say "Analyzing #{path.relative_path_from(base_path)} ..." doc = find(path.to_s.untaint, params) ref = doc[0].references(normalize_blocks: !params[:solo]) if ref.length == 0 say "no references found." else say "#{ref.length} references found." dst = nil each_format do |fmt| case fmt when 'ttx' res = doc.to_s tagged: true when 'txt' res = doc.to_s tagged: false when 'ref' res = ref.join("\n") else dst ||= parse(ref.join("\n")) res = format(dst, fmt) end out = extsub(path, ".#{fmt}") say "Writing #{out.relative_path_from(base_path)} ..." write res, out, base_path end end end end |