Sha256: 94008f40dab33c4d4d813ccd77a021bddd3019ad8c3a26b6650965d80b9fa7e4

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module GFSM
  module Commands
    class Version < BaseCommand

      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gfsm-0.8.0 lib/commands/version.rb
gfsm-0.7.0 lib/commands/version.rb
gfsm-0.6.0 lib/commands/version.rb