Sha256: 5bada1affc004ec6d24bf40eecd0a308418b157ca95623809431a08dd5f3c12a
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
require 'thor' require 'tmpdir' require 'fileutils' require_relative '../html2pdf' module Html2Pdf class CLI < Thor desc 'export', 'export html files to pdfs' method_option *AgileUtils::Options::BASE_DIR method_option *AgileUtils::Options::INC_WORDS method_option *AgileUtils::Options::EXC_WORDS method_option *AgileUtils::Options::IGNORE_CASE method_option *AgileUtils::Options::RECURSIVE method_option *AgileUtils::Options::VERSION def export opts = options.symbolize_keys unless Html2Pdf::Utils.required_softwares? 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 puts "Convert files to pdfs took #{elapsed} ms" end desc 'usage', 'Display usage information' def usage puts <<-EOT Usage: html2pdf export [OPTIONS] Options: -b, [--base-dir=BASE_DIR] # Base directory # Default: . (current directory) -n, [--inc-words=one two three] # List of words to be included in the result -x, [--exc-words=one two three] # List of words to be excluded from the result -i, [--ignore-case], [--no-ignore-case] # Match case insensitively # Default: true -r, [--recursive], [--no-recursive] # Search for files recursively # Default: true -v, [--version], [--no-version] # Display version information export html files to pdfs EOT end default_task :usage end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html2pdf-0.0.2 | lib/html2pdf/cli.rb |