Class: VimPK::CLI

Inherits:
Object
  • Object
show all
Includes:
Colorizer
Defined in:
lib/vimpk/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



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

def initialize(argv)
  @argv = argv
  @parser = Options.new(argv)
  @options = @parser.parse
  @command = determine_command
rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
  warn e.message
  abort help_message
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'lib/vimpk/cli.rb', line 19

def call
  if @command
    send(@command, *@argv)
    exit 0
  else
    puts @parser.parser
  end
end