Sha256: 7efcd525c3ecb170427749b20092ab4fbe3db04690f512877b8b32ccef07ae2a

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 Bytes

Contents

# frozen_string_literal: true

require 'thor'

module Goodwill
  class CLI < Thor
    class_option :verbose, type: :boolean
    class_option :username
    class_option :password
    class_option :threads

    def initialize(*args)
      super
      return if args[2][:current_command].name == 'help'

      username = options[:username] || ask('Username:')
      password = options[:password] || ask('Password:') { |q| q.echo = false }
      threads = options[:threads].to_i || 10
      @account = Goodwill::Account.new(username, password, threads)
    end

    desc 'auctions', "List all auctions you're currently bidding on"
    def auctions
      say "Your current auctions:\n"
      tp @account.in_progress
    end

    desc 'search SEARCH', 'Search for auctions matching SEARCH'
    def search(search)
      say 'Your search results:'
      tp @account.search(search)
    end

    desc 'bid ITEMID MAXBID', 'Bid MAXBID on ITEMID'
    def bid(itemid, maxbid)
      @accounts.bid(itemid, maxbid)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goodwill-0.4.4 lib/goodwill/cli.rb
goodwill-0.4.3 lib/goodwill/cli.rb
goodwill-0.4.1 lib/goodwill/cli.rb