Class: Gtmtech::Crypto::Subcommands::Account

Inherits:
Gtmtech::Crypto::Subcommand show all
Defined in:
lib/gtmtech/crypto/subcommands/account.rb

Class Method Summary collapse

Methods inherited from Gtmtech::Crypto::Subcommand

all_options, error, find, hidden?, parse, prettyname, validate

Class Method Details

.createObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 49

def self.create
  self.error "--name required" unless @@options[:name_given]
  self.error "--currencies required" unless @@options[:currencies_given]

  Data.load
  @@options[:currencies].split(",").each do |currency|
    Data.( @@options[:name], currency, @@options[:type], @@options[:url] )
  end
  Data.save
end

.descriptionObject



11
12
13
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 11

def self.description
  "manage accounts"
end

.executeObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 65

def self.execute
  verb = ARGV.shift
  case verb.downcase
  when "new", "create", "add"
    self.create
  when "list"
    self.list
  else
    self.error "account takes an action [new, list] . See --help for more info"
  end
end

.listObject



60
61
62
63
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 60

def self.list
  Data.load
  Data.list_accounts
end

.optionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 29

def self.options
  [{:name => :name,
    :description => "Name of the account",
    :short => 'n', 
    :type => :string},
   {:name => :currencies,
    :description => "Comma separated list of currencies this account supports",
    :short => 'c',
    :type => :string},
   {:name => :type,
    :description => "(optional) Type of account - options are wallet,exchange,bank",
    :short => 't',
    :type => :string},
   {:name => :url,
    :description => "(optional) URL for account website",
    :short => 'u',
    :type => :string}
  ]
end

.usageObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 15

def self.usage
  <<-EOS
Usage (crypto #{self.prettyname})

crypto #{self.prettyname} new --name=<s> --currencies=<s> [--type=<s> --url=<s>]
  - create a new account

crypto #{self.prettyname} list
  - list all accounts

Options:
EOS
end