Class: Gtmtech::Crypto::Subcommands::Account
- Inherits:
-
Gtmtech::Crypto::Subcommand
- Object
- Gtmtech::Crypto::Subcommand
- Gtmtech::Crypto::Subcommands::Account
- Defined in:
- lib/gtmtech/crypto/subcommands/account.rb
Class Method Summary collapse
- .create ⇒ Object
- .description ⇒ Object
- .execute ⇒ Object
- .list ⇒ Object
- .options ⇒ Object
- .usage ⇒ Object
Methods inherited from Gtmtech::Crypto::Subcommand
all_options, error, find, hidden?, parse, prettyname, validate
Class Method Details
.create ⇒ Object
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.add_account( @@options[:name], currency, @@options[:type], @@options[:url] ) end Data.save end |
.description ⇒ Object
11 12 13 |
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 11 def self.description "manage accounts" end |
.execute ⇒ Object
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 |
.list ⇒ Object
60 61 62 63 |
# File 'lib/gtmtech/crypto/subcommands/account.rb', line 60 def self.list Data.load Data.list_accounts end |
.options ⇒ Object
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. [{: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 |
.usage ⇒ Object
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 |