Class: CaptiveRelease::CLI

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

Constant Summary collapse

BUMP_TYPES =
%w[patch minor major].freeze
SEMVER_RE =
/\A\d+\.\d+\.\d+\z/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



12
13
14
# File 'lib/captive_release/cli.rb', line 12

def initialize(argv)
  @argv = argv
end

Class Method Details

.run(argv = ARGV) ⇒ Object



8
9
10
# File 'lib/captive_release/cli.rb', line 8

def self.run(argv = ARGV)
  new(argv.dup).run
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/captive_release/cli.rb', line 16

def run
  command = @argv.shift

  case command
  when "init"             then run_init
  when "new"              then run_release
  when "build"            then run_build
  when "version", "--version", "-v" then puts "captive-release #{VERSION}"
  when "help", "--help", "-h", nil  then print_help
  else
    puts error("Unknown command: #{command}")
    print_help
    exit 1
  end
end