Class: CreateGithubRelease::CommandLine::Options

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/create_github_release/command_line/options.rb

Overview

Stores and validates the command line options

Examples:

options = CreateGithubRelease::CommandLine::Options.new
options.release_type = 'major'
options.valid? #=> true
options.errors #=> []

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) {|self| ... } ⇒ Options

Create a new instance of this class

Examples:

No arguments or block given

options = CreateGithubRelease::CommandLine::Options.new
options.release_type #=> nil
options.valid? #=> false
options.errors #=> ["--release-type must be given and be one of 'major', 'minor', 'patch'"]

With keyword arguments

config = { release_type: 'major', default_branch: 'main', quiet: true }
options = CreateGithubRelease::CommandLine::Options.new(**config)
options.release_type #=> 'major'
options.default_branch #=> 'main'
options.quiet #=> true
options.valid? #=> true

with a configuration block

options = CreateGithubRelease::CommandLine::Options.new do |o|
  o.release_type = 'major'
  o.default_branch = 'main'
  o.quiet = true
end
options.release_type #=> 'major'
options.default_branch #=> 'main'
options.quiet #=> true
options.valid? #=> true

Yields:

  • (self)

    an initialization block

Yield Parameters:

Yield Returns:

  • (void)

    the return value is ignored



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/create_github_release/command_line/options.rb', line 125

def initialize(**options)
  assert_no_unknown_options(options)
  options.each { |k, v| instance_variable_set("@#{k}", v) }

  self.quiet ||= false
  self.verbose ||= false
  self.pre ||= false
  @errors = []

  yield(self) if block_given?

  @validator = CommandLine::Validator.new(self)

  valid?
end

Instance Attribute Details

#changelog_pathString

the path to the changelog file

Examples:

options = CreateGithubRelease::CommandLine::Options.new(changelog_path: 'CHANGELOG.md')
options.changelog_path #=> 'CHANGELOG.md'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 73

#default_branchString

the default branch of the repository

Examples:

options = CreateGithubRelease::CommandLine::Options.new(default_branch: 'main')
options.default_branch #=> 'main'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 31

#last_release_versionString

the version of the last release

Examples:

options = CreateGithubRelease::CommandLine::Options.new(last_release_version: '0.1.1')
options.last_release_version #=> '0.1.1'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 52

#next_release_versionString

the version of the next release

Examples:

options = CreateGithubRelease::CommandLine::Options.new(next_release_version: '1.0.0')
options.next_release_version #=> '1.0.0'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 59

#quietBoolean

if true, suppresses all output

Examples:

options = CreateGithubRelease::CommandLine::Options.new(quiet: true)
options.quiet #=> true

Returns:

  • (Boolean)


# File 'lib/create_github_release/command_line/options.rb', line 80

#release_branchString

the branch use to create the release

Examples:

options = CreateGithubRelease::CommandLine::Options.new(release_branch: 'release-v1.0.0')
options.release_branch #=> 'release-v1.0.0'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 38

#release_pr_labelString

the label to apply to the release pull request

Examples:

options = CreateGithubRelease::CommandLine::Options.new(release_pr_label: 'release')
options.release_pr_label #=> 'release'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 66

#release_typeString

the type of release to create

Must be one of the VALID_RELEASE_TYPES

Examples:

options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
options.release_type #=> 'major'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 21

#remoteString

the name of the remote to use to access Github

Examples:

options = CreateGithubRelease::CommandLine::Options.new(remote: 'origin')
options.remote #=> 'origin'

Returns:

  • (String)


# File 'lib/create_github_release/command_line/options.rb', line 45

#verboseBoolean

if true, enables verbose output

Examples:

options = CreateGithubRelease::CommandLine::Options.new(verbose: true)
options.verbose #=> true

Returns:

  • (Boolean)


# File 'lib/create_github_release/command_line/options.rb', line 87