class OAuth::CLI
Constants
- ALIASES
Public Class Methods
new(stdout, stdin, stderr, command, arguments)
click to toggle source
# File lib/oauth/cli.rb, line 24 def initialize(stdout, stdin, stderr, command, arguments) klass = get_command_class(parse_command(command)) @command = klass.new(stdout, stdin, stderr, arguments) @help_command = HelpCommand.new(stdout, stdin, stderr, []) end
puts_red(string)
click to toggle source
# File lib/oauth/cli.rb, line 12 def self.puts_red(string) puts "\033[0;91m#{string}\033[0m" end
Public Instance Methods
run()
click to toggle source
# File lib/oauth/cli.rb, line 30 def run @command.run end
Private Instance Methods
get_command_class(command)
click to toggle source
# File lib/oauth/cli.rb, line 36 def get_command_class(command) Object.const_get("OAuth::CLI::#{command.camelize}Command") end
parse_command(command)
click to toggle source
# File lib/oauth/cli.rb, line 40 def parse_command(command) case command = command.to_s.downcase when "--version", "-v" "version" when "--help", "-h", nil, "" "help" when *ALIASES.keys ALIASES[command] when *ALIASES.values command else OAuth::CLI.puts_red "Command '#{command}' not found" "help" end end