Class: Html2Pdf::CLI
- Inherits:
-
Thor
- Object
- Thor
- Html2Pdf::CLI
- Defined in:
- lib/html2pdf/cli.rb
Instance Method Summary collapse
Instance Method Details
#export ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/html2pdf/cli.rb', line 16 def export opts = .symbolize_keys unless Html2Pdf::Utils.softwares_installed? fail 'You must have valid `wkhtmltopdf` and `ghostscript` installation' end if opts[:version] puts "You are using Html2Pdf version #{Html2Pdf::VERSION}" exit end input_files = CodeLister.files base_dir: opts[:base_dir], exts: %w(html xhtml), recursive: true elapsed = AgileUtils::FileUtil.time do Html2Pdf::Utils.to_pdfs(input_files) end generated_files = AgileUtils::FileUtil.add_suffix(input_files, 'pdf') AgileUtils::FileUtil.tar_gzip_files(generated_files, 'html2pdf-output.tar.gz') AgileUtils::FileUtil.delete(generated_files) puts "Convert files to pdfs took #{elapsed} ms" puts "Your final output is #{File.absolute_path('html2pdf-output.tar.gz')}" end |
#usage ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/html2pdf/cli.rb', line 44 def usage puts "Usage:\n html2pdf export [OPTIONS]\n\nOptions:\n -b, [--base-dir=BASE_DIR] # Base directory\n # Default: . (current directory)\n -n, [--inc-words=one two three] # List of words to be included in the result\n -x, [--exc-words=one two three] # List of words to be excluded from the result\n -i, [--ignore-case], [--no-ignore-case] # Match case insensitively\n # Default: true\n -r, [--recursive], [--no-recursive] # Search for files recursively\n # Default: true\n -v, [--version], [--no-version] # Display version information\n\nexport multiple html files to pdfs\n EOT\nend\n" |