Class: Pdfs2Pdf::CLI
- Inherits:
-
Thor
- Object
- Thor
- Pdfs2Pdf::CLI
- Defined in:
- lib/pdfs2pdf/cli.rb
Instance Method Summary collapse
Instance Method Details
#merge ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pdfs2pdf/cli.rb', line 17 def merge opts = .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.expand_path(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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pdfs2pdf/cli.rb', line 40 def usage puts "Usage:\n\n pdfs2pdf\n\nOptions:\n -b, [--base-dir=BASE_DIR] # Base directory\n # Default: . (current directory)\n -r, [--recursive], [--no-recursive] # Search for files recursively\n # Default: --recursive\n -v, [--version], [--no-version] # Display version information\n\nCombine multiple pdfs into one file with combined table of content\n\n EOT\nend\n" |