Sha256: de1a6b1c88f8db4fcf2da33a0273a5e4d57d71afcd282d6a97499a577e866847

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module Klipbook
  module Commands
    class Command
      def initialize(logger=Logger.new)
        @logger = logger
      end

      def run!(options)
        run_command!(book_source(options), options)
      end

      def run_command!
        raise "Implement me"
      end

      private

      attr_reader :logger

      def book_source(options)
        Klipbook::Sources::Source.build(options)
      end

      def exit_unless_valid_source(options)
        unless options.from_file
          logger.error "Error: You must specify `--from-file` as an input."
          exit 127
        end
      end

      def exit_unless_valid_count(options)
        unless options.count > 0
          logger.error "Error: Specify a maximum book count greater than 0."
          exit 127
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
klipbook-4.0.0 lib/klipbook/commands/command.rb