Class: HexaPDF::CLI::Batch
- Defined in:
- lib/hexapdf/cli/batch.rb
Overview
Execute the same command for multiple input files.
Instance Method Summary collapse
-
#execute(command, *files) ⇒ Object
:nodoc:.
-
#initialize ⇒ Batch
constructor
:nodoc:.
Methods included from Command::Extensions
Constructor Details
#initialize ⇒ Batch
:nodoc:
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hexapdf/cli/batch.rb', line 43 def initialize #:nodoc: super('batch', takes_commands: false) short_desc("Execute a single command on multiple files") long_desc(" This command allows executing a single command for multiple input files, thereby reducing\n the overall execution time.\n\n The first argument is used as a hexapdf command line (but without the binary name) and\n the rest as input files. The specified command will be executed for each input file, with\n {} being replaced by the file name.\n EOF\nend\n".gsub!(/^ */, '')) |
Instance Method Details
#execute(command, *files) ⇒ Object
:nodoc:
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hexapdf/cli/batch.rb', line 56 def execute(command, *files) #:nodoc: args = Shellwords.split(command) files.each do |file| begin HexaPDF::CLI::Application.new.parse(args.map {|a| a.gsub(/{}/, file)}) rescue if command_parser.verbosity_warning? $stderr.puts "Error processing '#{file}': #{$!.message}" end end end end |