Class: Stg::CLI

Inherits:
Object
  • Object
show all
Extended by:
Actions, Help
Defined in:
lib/stg.rb

Instance Attribute Summary

Attributes included from DiffCalc

#cnt, #mem, #new_s, #old_s

Class Method Summary collapse

Methods included from Actions

branch, checkout, commit, diff, log, p_initialize, reset, stage

Methods included from DiffCalc

#build_sequences, #compute_diff, #differencing, #initialize, #print_diff, #print_line

Methods included from Help

print_usage

Class Method Details

.startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/stg.rb', line 11

def self.start
  begin
    OptionParser.new do |opts|
      opts.banner = 'Usage: stg <command> [options]'

      opts.on('-v', '--version', 'Show version') do
        puts "stg version #{VERSION}"
        exit
      end

      opts.on('-h', '--help', 'Show this help') do
        puts print_usage
        exit
      end
    end.order!
  rescue OptionParser::ParseError
    # Ignore unknown options, let command handlers deal with them
  end

  command = ARGV.shift
  if !command || command.empty?
    puts print_usage
    return
  elsif command == 'init'
    p_initialize
    return
  else
    return unless check_program_exists
  end

  case command
  when 'commit'
    commit
  when 'diff'
    diff
  when 'test'
    test
  when 'stage'
    stage
  when 'check_router'
    check_router
  when 'reset'
    reset
  when 'log'
    log
  when 'checkout'
    checkout
  when 'branch'
    branch
  when 'help'
    puts print_usage
    exit 1
  when nil
    puts print_usage
    exit 1
  else
    puts "Unknown command: #{command}"
    exit 1
  end
end