class GitVersionBumper::CLI

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

Constants

ERROR_EXIT_STATUS
MAJOR_VERSION_TYPE

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

MINOR_VERSION_TYPE
PATCH_VERSION_TYPE
SUCCESS_EXIT_STATUS
VALID_BUMP_TYPES

Public Instance Methods

bump(version_type) click to toggle source
# 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

Private Instance Methods

bumper_for(version_type) click to toggle source
# File lib/git_version_bumper/cli.rb, line 42
def bumper_for(version_type)
  case version_type.upcase
  when MAJOR_VERSION_TYPE
    VersionBumper::MajorVersionBumper.new(FileUtils.pwd)
  when MINOR_VERSION_TYPE
    VersionBumper::MinorVersionBumper.new(FileUtils.pwd)
  when PATCH_VERSION_TYPE
    VersionBumper::PatchVersionBumper.new(FileUtils.pwd)
  else
    fail Errors::InvalidVersionBumpType
  end
end