Class: GitVersionBumper::CLI

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

Overview

Handles logic associated with command line interface. Uses Thor to make interaction more pleasant.

Constant Summary collapse

SUCCESS_EXIT_STATUS =
0
ERROR_EXIT_STATUS =
1
MAJOR_VERSION_TYPE =

Version number naming shema based on Semantic Versioning See semver.org/ for more details

'MAJOR'.freeze
MINOR_VERSION_TYPE =
'MINOR'.freeze
PATCH_VERSION_TYPE =
'PATCH'.freeze
VALID_BUMP_TYPES =
[
  MAJOR_VERSION_TYPE,
  MINOR_VERSION_TYPE,
  PATCH_VERSION_TYPE
].freeze

Instance Method Summary collapse

Instance Method Details

#bump(version_type) ⇒ Object



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

def bump(version_type)
  bumper = bumper_for(version_type)
  bumper.bump
  # add logic to check for accepted versions here
  SUCCESS_EXIT_STATUS
rescue Errors::NotRepositoryError
  $stderr.puts 'Error: Directory is not a repository'
  ERROR_EXIT_STATUS
rescue Errors::InvalidVersionBumpType
  $stderr.puts 'Error: Invalid TYPE for version bump.' \
    " TYPE must be one of #{VALID_BUMP_TYPES.join(', ')}"
  ERROR_EXIT_STATUS
end