Class: Pdfs2Pdf::CLI
- Inherits:
-
Thor
- Object
- Thor
- Pdfs2Pdf::CLI
- Defined in:
- lib/pdfs2pdf/cli.rb
Instance Method Summary collapse
Instance Method Details
#merge ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pdfs2pdf/cli.rb', line 8 def merge opts = .deep_symbolize_keys if opts[:version] puts "You are using Pdfs2Pdf version #{Pdfs2Pdf::VERSION}" exit end base_dir = File.(opts[:base_dir]) pdf_files = CodeLister.files base_dir: base_dir, exts: %w[pdf], recursive: opts[:recursive] # Note: we remove the output file from the list of file here first if any output_file = "pdfs2pdf_#{File.basename(File.(base_dir))}.pdf" pdf_files.delete_if { |file| file == "./#{output_file}" } # We make sure that the index.html.pdf is the first element in the list if applicable index_file = pdf_files.delete("./index.html.pdf") pdf_files.unshift(index_file) if index_file create_pdfmarks(pdf_files, base_dir) merge_pdfs(pdf_files, output_file) end |
#usage ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pdfs2pdf/cli.rb', line 31 def usage puts <<-EOT Usage: pdfs2pdf Options: -b, [--base-dir=BASE_DIR] # Base directory # Default: . (current directory) -r, [--recursive], [--no-recursive] # Search for files recursively # Default: --recursive -v, [--version], [--no-version] # Display version information Combine multiple pdfs into one file with combined table of content EOT end |