   arguments << access_token if method_args.include?(:access_token)
   arguments.push(*ARGV)
 
-  # Ruby **args expansion doesn't work as I expected, that's why the extra if.
-  # pry(main)> def xxx(*args) args; end
-  # pry(main)> xxx(**{})
-  # => [{}]
-  if options
-    STDERR.puts("~ Terminal::API.#{command}(*#{arguments.inspect}, **#{options.inspect})\n\n")
-    puts Terminal::API.send(command, *arguments, **options)
-  else
-    STDERR.puts("~ Terminal::API.#{command}(*#{arguments.inspect})\n\n")
-    puts Terminal::API.send(command, *arguments)
-  end
+  api_call(command, arguments, options)
 end
 
 __END__


require File.expand_path('../../lib/terminal.com', __FILE__)
require 'json'

# TODO (later): Don't force tokens for methods that don't need them.
# TODO: terminal.com configure -> ask for the credentials and save them.

def usage
  DATA.read

  if method_args.include?(:options)
    options = ARGV.reduce(Hash.new) do |buffer, argument|
      if argument.match(/^--(.+)=(.+)$/)
        buffer[$1.to_sym] = $2
      elsif argument.match(/^--no-(.+)$/)
        buffer[$1.to_sym] = false
      elsif argument.match(/^--(.+)$/)
        buffer[$1.to_sym] = true
      end

      buffer
    end

    ARGV.delete_if { |argument| argument.start_with?('--') }
  end

  arguments = []
