Class: SRC::CLI

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

Instance Method Summary collapse

Instance Method Details

#check(*args) ⇒ Object



18
19
20
# File 'lib/src/cli.rb', line 18

def check(*args)
  SRC.check
end

#cut(*args) ⇒ Object



10
11
12
# File 'lib/src/cli.rb', line 10

def cut(*args)
  SRC::Branch.new(args[0]).cut
end

#merge(*args) ⇒ Object



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

def merge(*args)
  SRC::Branch.new(args[0]).merge
end

#optionsObject



22
23
24
# File 'lib/src/cli.rb', line 22

def options
  @options ||= parse
end

#parseObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/src/cli.rb', line 26

def parse
  key = :base_args
  argv.inject({}) do |args, val|
    if val[0] == '-'
      key = val.gsub('-', '').to_sym
      args[key] ||= nil
    elsif args[key]
      args[key] = [args[key]] unless args[key].kind_of? Array
      args[key] << val
    else
      args[key] = val
    end
    args
  end
end

#runObject



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

def run
  public_send(*options[:base_args])
end