Class: MercadoBitcoin::Console::CommandParse
- Inherits:
-
Object
- Object
- MercadoBitcoin::Console::CommandParse
- Defined in:
- lib/mercado_bitcoin/console/command_parse.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
Returns the value of attribute console.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#console ⇒ Object
Returns the value of attribute console.
2 3 4 |
# File 'lib/mercado_bitcoin/console/command_parse.rb', line 2 def console @console end |
Class Method Details
.parse(console) ⇒ Object
5 6 7 |
# File 'lib/mercado_bitcoin/console/command_parse.rb', line 5 def parse(console) new.parse(console) end |
Instance Method Details
#global_options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mercado_bitcoin/console/command_parse.rb', line 21 def parser. do |opts| opts.on("-k", "--api-key MB_API_KEY", "api key") do |v| console.[:code] = v end opts.on("-s", "--secret-key MB_SECRET_KEY", "secret key") do |v| console.[:key] = v end opts.on("--coin-pair MB_COIN_PAIR", [:brlbtc, :brlltc, :brl], "coin_pair (brlbtc | brlltc | brl), padrão: brlbtc") do |v| console.[:coin_pair] = v.to_s.to_upper end opts.on("--[no-]pretty-print", "Mostra (ou não) o json de saida formatado, saída formatada é a default") do |v| console.[:pretty_print] = v end opts.on("--[no-]debug", "debug info printed") do |v| console.[:debug] = v end end end |
#parse(console) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mercado_bitcoin/console/command_parse.rb', line 10 def parse(console) @console = console parser.add_command(CmdParse::HelpCommand.new, default: true) parser.add_command(CmdParse::VersionCommand.new) MercadoBitcoin::Console::Commands::Base.command_classes.each do |command| parser.add_command(command.new(console)) end parser.parse end |
#parser ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/mercado_bitcoin/console/command_parse.rb', line 45 def parser @parser ||= CmdParse::CommandParser.new.tap do |init| init..program_name = "mb_console" init..version = MercadoBitcoin::VERSION init.. = "MercadoBitcoin Console" init.help_line_width = 160 end end |