Sha256: a104d442ea4165f1331c580c555bb53d06159bf1560abe9ca46efabc2a47fef6
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'optparse' module LocateImages class CLI def self.run new.call end def call initialize_default_options parse_options run end def initialize_default_options @directory = "." @format = "csv" @output = $stdout end def parse_options OptionParser.new do |opts| opts.banner = "Usage: locate-images [options] [directory]" opts.on("-f", "--format FORMAT", ["csv", "html"], "csv by default. Accepts `csv` or `html`") do |f| @format = f end opts.on("-o", "--output FILE", "stdout by default") do |f| @output = File.open(f, 'w') end end.parse! @directory = ARGV[0] if ARGV[0] raise "You can only pass one directory" if ARGV.size > 1 rescue => e puts e.message exit 1 end def run formatter.call(images: images, output: @output) end def images LoadImages.call(image_paths: ListImages.call(directory: @directory)) end def formatter { "csv" => GenerateCSV, "html" => GenerateHTML }.fetch(@format) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locate-images-0.1.0 | lib/locate_images/cli.rb |