Class: Reviewr::CLI::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewr/cli/main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, input = STDIN, output = STDOUT) ⇒ Main

Returns a new instance of Main.



9
10
11
12
13
14
15
16
17
# File 'lib/reviewr/cli/main.rb', line 9

def initialize(args, input = STDIN, output = STDOUT)
  @command = args.shift
  if @command == "-p"
    Git.instance = PretendGit.new(output)
    @command = args.shift
  end
  @arguments = args
  @input, @output = input, output
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



7
8
9
# File 'lib/reviewr/cli/main.rb', line 7

def arguments
  @arguments
end

#cObject (readonly)

Returns the value of attribute c.



6
7
8
# File 'lib/reviewr/cli/main.rb', line 6

def c
  @c
end

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/reviewr/cli/main.rb', line 6

def command
  @command
end

Instance Method Details

#build_commandObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/reviewr/cli/main.rb', line 23

def build_command
  unless @c
    case command
    when "request"
      @c = Request.new(Project.new, @input, @output)
    when "accept"
      @c = Accept.new(Project.new, @input, @output)
    else
      @c = Help.new(Project.new, @input, @output)
    end

    @c.arguments = arguments
  end
  @c
end

#runObject



19
20
21
# File 'lib/reviewr/cli/main.rb', line 19

def run
  build_command.call
end