Class: Github::Auth::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/github/auth/cli.rb

Overview

Command Line Interface for parsing and executing commands

Constant Summary collapse

COMMANDS =
%w(add remove)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
# File 'lib/github/auth/cli.rb', line 8

def initialize(argv)
  @command   = argv.shift
  @usernames = argv
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



4
5
6
# File 'lib/github/auth/cli.rb', line 4

def command
  @command
end

#usernamesObject (readonly)

Returns the value of attribute usernames.



4
5
6
# File 'lib/github/auth/cli.rb', line 4

def usernames
  @usernames
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
# File 'lib/github/auth/cli.rb', line 13

def execute
  if COMMANDS.include?(command) && !usernames.empty?
    send command
  elsif command == '--version'
    print_version
  else
    print_usage
  end
end