Class: Goodwill::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/goodwill/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



12
13
14
15
16
17
18
19
20
# File 'lib/goodwill/cli.rb', line 12

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

Instance Method Details

#auctionsObject



23
24
25
26
27
28
29
30
31
# File 'lib/goodwill/cli.rb', line 23

def auctions
  say "Your current auctions:\n"
  res = @account.in_progress
  if res.empty?
    puts 'No items found.'
  else
    tp res
  end
end

#bid(itemid, maxbid) ⇒ Object



45
46
47
# File 'lib/goodwill/cli.rb', line 45

def bid(itemid, maxbid)
  @accounts.bid(itemid, maxbid)
end

#search(search) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/goodwill/cli.rb', line 34

def search(search)
  say 'Your search results:'
  res = @account.search(search)
  if res.empty?
    puts 'No items found.'
  else
    tp res
  end
end