Class: Coinpare::CLI

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

Overview

Handle the application command line parsing and the dispatch to various command objects

Constant Summary collapse

Error =

Error raised by this runner

Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#coins(*names) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/coinpare/cli.rb', line 60

def coins(*names)
  if options[:help]
    invoke :help, ["coins"]
  else
    require_relative "commands/coins"
    Coinpare::Commands::Coins.new(names, options).execute
  end
end

#help(*args) ⇒ Object



16
17
18
19
20
21
# File 'lib/coinpare/cli.rb', line 16

def help(*args)
  font = TTY::Font.new(:standard)
  pastel = Pastel.new(enabled: !options["no-color"])
  puts pastel.yellow(font.write("Coinpare"))
  super
end

#holdingsObject



106
107
108
109
110
111
112
113
# File 'lib/coinpare/cli.rb', line 106

def holdings(*)
  if options[:help]
    invoke :help, ["holdings"]
  else
    require_relative "commands/holdings"
    Coinpare::Commands::Holdings.new(options).execute
  end
end

#markets(name = "BTC") ⇒ Object



144
145
146
147
148
149
150
151
# File 'lib/coinpare/cli.rb', line 144

def markets(name = "BTC")
  if options[:help]
    invoke :help, ["markets"]
  else
    require_relative "commands/markets"
    Coinpare::Commands::Markets.new(name, options).execute
  end
end

#versionObject



154
155
156
157
# File 'lib/coinpare/cli.rb', line 154

def version
  require_relative "version"
  puts "v#{Coinpare::VERSION}"
end