Class: Coffer::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/coffer/cli.rb', line 59

def self.handle_no_command_error(command, has_namespace=$thor_runner)
  coin = Coffer::Registry.instance.find(command)

  if coin.nil?
    # warn "Unable to find a coin with a name or symbol of #{ coin }"
    super
    return
  end

  ARGV.shift
  coin.call_rpc( *ARGV )
end

Instance Method Details

#install(coin) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/coffer/cli.rb', line 20

def install(coin)
  coin = Coffer::Registry.instance.find( coin )

  if coin.nil?
    warn "Unable to find a coin with a name or symbol of #{ coin }"
  end

  warn "installing coin: #{ coin.name } (#{coin.symbol})"

  installer = Coffer::Installer.new(coin)
  if installer.install
    puts "success!"
  else
    puts "Failed to install coin..."
  end
end

#listObject



8
9
10
11
12
# File 'lib/coffer/cli.rb', line 8

def list
  Coffer::Registry.instance.coins.each do |coin|
    puts "%-20s (%s)" % [ coin.name, coin.symbol ]
  end
end

#searchObject



15
16
17
# File 'lib/coffer/cli.rb', line 15

def search
  warn "not implemented"
end

#start(coin) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/coffer/cli.rb', line 38

def start(coin)
  coin = Coffer::Registry.instance.find(coin)

  if coin.nil?
    warn "Unable to find a coin with a name or symbol of #{ coin }"
  end

  coin.start
end

#stop(coin) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/coffer/cli.rb', line 49

def stop(coin)
  coin = Coffer::Registry.instance.find(coin)

  if coin.nil?
    warn "Unable to find a coin with a name or symbol of #{ coin }"
  end

  coin.stop
end