Class: GFSM::Commands::Version

Inherits:
BaseCommand show all
Defined in:
lib/commands/version.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdout

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from GFSM::Commands::BaseCommand

Class Method Details

.helpObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/commands/version.rb', line 7

def self.help
  cli_info = GFSM::Tools::VersionBumperSettings.cli_info

  <<~HELP
  Usage:
  gfsm version [help|bump|current] #{cli_info[:usage]}

  Commands:
  help                                  # Prints this help
  bump                                  # Bump the current version based on the commits changelog trailer and the configuration file
  current                               # Print the current version, without bumping it

  Options: \n#{cli_info[:options]}

  Environment variables: \n#{cli_info[:environment_variables]}
  HELP
end

Instance Method Details

#run(args = []) ⇒ Object



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
# File 'lib/commands/version.rb', line 25

def run(args = [])
  case args.shift
  when 'bump'
    settings = GFSM::Tools::VersionBumperSettings.new(args)
    version_bumper = GFSM::Tools::VersionBumper.new(settings)
    version = version_bumper.execute

    GFSM::Output.puts(version)
  when 'current'
    settings = GFSM::Tools::VersionBumperSettings.new(args)
    version = GFSM::Tools::CurrentVersionLoader.load_current_version(settings.repository, settings.initial_version)

    if settings.prerelease
      version.add_prerelease_suffix!(settings.prerelease_name)
    end

    GFSM::Output.puts(version)
  when 'help'
    GFSM::Output.puts(GFSM::Commands::Version.help)
  else
    GFSM::Output.warn(GFSM::Commands::Version.help)
  end

  true
end