class XeroCLI::OptionsParser

Attributes

opt[R]
options[R]

Public Class Methods

new() click to toggle source
# File lib/xero_cli/options_parser.rb, line 5
def initialize
  @options = {}
  @opt = OptionParser.new
end

Public Instance Methods

xero() click to toggle source
# File lib/xero_cli/options_parser.rb, line 10
def xero
  banner
  separators
  binds
  opt
end

Private Instance Methods

banner() click to toggle source
binds() click to toggle source
# File lib/xero_cli/options_parser.rb, line 45
def binds
  opt.on('-s', '--set GUID', 'Set GUID') do |set_guid|
    options[:set_guid] = set_guid
  end

  opt.on('-g', '--guid', 'Show current GUID') do |show_guid|
    options[:show_guid] = show_guid
  end

  opt.on('--get-guid', 'Open browser to get GUID') do |get_guid|
    options[:get_guid] = get_guid
  end

  opt.on('-a', '--accounts [TYPE]', 'Show available accounts') do |show_accounts|
    options[:show_accounts] = 'ALL'
    options[:show_accounts] = show_accounts if show_accounts
  end

  opt.on('-h', '--help', 'help') do |help|
    options[:help] = help
  end

  opt.on('--spend AMOUNT', 'Amount in dollars (e.g. 456.78)') do |spend|
    options[:spend] = spend
  end

  opt.on('--receive AMOUNT', 'Amount in dollars (e.g. 456.78)') do |receive|
    options[:receive] = receive
  end

  opt.on('--transfer AMOUNT', 'Amount in dollars (e.g. 456.78)') do |transfer|
    options[:transfer] = transfer
  end

  opt.on('--balance BANK_NAME', 'bank name [under construct]') do |balance|
    options[:balance] = balance
  end

  opt.on('--on DATE', 'Time in format dd-mm-yyyy') do |on|
    options[:on] = on
  end

  opt.on('--as TYPE', 'Category account name') do |as|
    options[:as] = as
  end

  opt.on('--from NAME', 'Sender`s name (Bank or Contact)') do |from|
    options[:from] = from
  end

  opt.on('--to NAME', 'Receiver`s name (Bank or Contact)') do |to|
    options[:to] = to
  end
end
separators() click to toggle source
# File lib/xero_cli/options_parser.rb, line 25
def separators
  opt.separator  ''
  opt.separator  'Commands'
  opt.separator  ''
  opt.separator  "     xero --set 'YOUR_XERO_GUID'                                                      // saves you GUID to json file"
  opt.separator  '     xero --guid                                                                      // shows current GUID'
  opt.separator  '     xero --get-guid                                                                  // opens browser where you can get your GUID'
  opt.separator  '     xero --accounts                                                                  // shows all available accounts'
  opt.separator  "     xero --accounts BANK                                                             // shows all accounts with type 'BANK'"
  opt.separator  ''
  opt.separator  "     xero --receive 45.67 --from 'Contact name' --to 'Bank Account Name'              // '--to' is optional, uses Stripe account if not set"
  opt.separator  "     xero --spend 45.67 --from 'Bank Account Name' --to 'Contact name'                // '--from' is optional, uses Stripe account if not set"
  opt.separator  "          --as 'Category Account Name'                                                // sets Category for transaction, uses 'Sales' category if not set"
  opt.separator  "          --on 'dd-MM-yyyy'                                                           // sets the Date for transaction, uses 'Time.now' if not set"
  opt.separator  ''
  opt.separator  "     xero --transfer 1000 --from 'Stripe Merchant Account' --to 'Bank Account Name'   // transfers money from one bank to another"
  opt.separator  ''
  opt.separator  'Options'
end