Class: Phper::CLI

Inherits:
CommandLineUtils::CLI
  • Object
show all
Includes:
Phper
Defined in:
lib/phper/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Phper

#decode, #encode, #git_remote, #git_remotes, #git_root, #in_git?, #name_of_key

Constructor Details

#initialize {|_self| ... } ⇒ CLI

Returns a new instance of CLI.

Yields:

  • (_self)

Yield Parameters:

  • _self (Phper::CLI)

    the object that the method was called on



7
8
9
10
11
12
# File 'lib/phper/cli.rb', line 7

def initialize
  super
  @out=STDOUT
  @commands = Commands.new
  yield self if block_given?
end

Instance Attribute Details

#outObject

Returns the value of attribute out.



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

def out
  @out
end

Instance Method Details

#dispatch(cmd, cmd_argv) ⇒ Object



13
14
15
16
# File 'lib/phper/cli.rb', line 13

def dispatch(cmd,cmd_argv)
  raise "Unknown command. #{cmd}" unless @commands.commands.include?(cmd)
  @commands.send(cmd.gsub(/:/,"_"))
end

#versionObject



17
18
19
20
21
22
# File 'lib/phper/cli.rb', line 17

def version
  File.open(File.join(File.dirname(__FILE__) ,
                      "..","..","VERSION"),"r") { |file|
    @out.puts file.gets
  }
end