Sha256: f5befe8493b0a3314211ef15e69d78877dc04dbc1d01e65325461ec3eb06c14d
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'thor' module Klipbook class CLI < Thor desc 'list CLIPPINGS_FILE', 'List the books in the clippings file' def list(clippings_file=nil) if (clippings_file.nil?) puts 'Please provide a CLIPPINGS_FILE' exit 1 end clippings_file = ensure_clippings_file_exists(clippings_file) Klipbook::Runner.new(clippings_file).list_books end desc 'summarise CLIPPINGS_FILE BOOK_NUMBER OUTPUT_FILE', 'Output an html summary of the clippings for a book' method_option :include_pages, :aliases => '-p', :desc => 'Include page numbers in output when available' def summarise(clippings_file=nil, book_number=nil, output_file=nil) if (clippings_file.nil? or book_number.nil? or output_file.nil?) puts 'Please provide a CLIPPINGS_FILE, BOOK_NUMBER, and OUTPUT_FILE' exit 1 end clippings_file = ensure_clippings_file_exists(clippings_file) book_number = book_number.to_i Klipbook::Runner.new(clippings_file).print_book_summary(book_number, File.open(output_file, 'w'), options) end map '-v' => :version desc 'version', 'Display Klipbook version' def version puts "Klipbook #{Klipbook::VERSION}" end no_tasks do def ensure_clippings_file_exists(clippings_file) unless File.exist?(clippings_file) $stderr.puts "Clippings file doesn't exist: #{clippings_file}" exit 1 end File.open(clippings_file, 'r') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
klipbook-0.3.0 | lib/klipbook/cli.rb |