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.


9
10
11
12
13
14
15
16
# File 'lib/goodwill/cli.rb', line 9

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 }
  @account = Goodwill::Account.new(username, password)
end

Instance Method Details

#auctionsObject


19
20
21
22
# File 'lib/goodwill/cli.rb', line 19

def auctions
  say "Your current auctions:\n"
  tp @account.in_progress
end

#bid(itemid, maxbid) ⇒ Object


31
32
33
# File 'lib/goodwill/cli.rb', line 31

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

#search(search) ⇒ Object


25
26
27
28
# File 'lib/goodwill/cli.rb', line 25

def search(search)
  say 'Your search results:'
  tp @account.search(search)
end