Sha256: 7a03e710253b92a5a97537921504671e651cfd384b61b258ec5ae28c73080be4

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

module OcrFile
  class Cli
    attr_reader :args

    def initialize(args)
      @args = args
    end

    def valid?
      return true if args.size == 2 || args.size == 3
      false
    end

    def invalid?
      !valid?
    end

    def call
      # TODO: Use ConsoleStyle::Functions
      # TODO: Heading and better CLI interface
      # Simple cli for now
      puts "OCR Tool © Jason Chalom 2022, Version: #{OcrFile::VERSION}"
      abort "File path, Save Folder Paths, and output type (pdf, txt) are required!" if invalid?

      # Using default config for now
      original_file_path = args[0]
      save_file_path = args[1]
      output_type = args[2]

      document = OcrFile::Document.new(original_file_path: original_file_path, save_file_path: save_file_path)

      if output_type.to_s.downcase.include?('pdf')
        document.to_pdf
      elsif output_type.to_s.downcase.include?('txt') || output_type.to_s.downcase.include?('text')
        document.to_text
      else # Display in console
        puts document.to_s
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ocr-file-0.0.10 lib/ocr-file/cli.rb
ocr-file-0.0.8 lib/ocr-file/cli.rb
ocr-file-0.0.7 lib/ocr-file/cli.rb
ocr-file-0.0.6 lib/ocr-file/cli.rb
ocr-file-0.0.4 lib/ocr-file/cli.rb
ocr-file-0.0.3 lib/ocr-file/cli.rb
ocr-file-0.0.2 lib/ocr-file/cli.rb