Sha256: 01b1fac62a4f80d6d959ff9017a8835119a77b40958433f8df91e61b9747761d

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

module MaxAmount
  module CLI
    extend MaxAmount::Options

    def self.call(custom_string:)
      options = MaxAmount::Options.ask

      case options[:m]
      when '1'
        str = Dotenv.load('../.env')['TEST_STRING']
      when '2'
        str = SecureRandom.hex(options[:l].to_i)
      when '3'
        str = custom_string
      end

      params = {
        text: str,
        nmax: options[:n]&.to_i
      }

      params[:text] = params[:text].to_s.chomp unless params[:text].is_a?(String)

      begin
        output = MaxAmount::Seeker.new(params).check_errors.search.join("\n")
        puts output
      rescue MaxAmount::Error => e
        message = e.message
        puts message
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
max_amount-0.1.1 lib/max_amount/cli.rb
max_amount-0.1.0 lib/max_amount/cli.rb