class Milestoner::CLI::Parsers::Core

Handles parsing of Command Line Interface (CLI) core options.

Attributes

client[R]
configuration[R]

Public Class Methods

call(configuration = Configuration::Loader.call, client: CLIENT) click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 14
def self.call configuration = Configuration::Loader.call, client: CLIENT
  new(configuration, client: client).call
end
new(configuration = Configuration::Loader.call, client: CLIENT) click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 18
def initialize configuration = Configuration::Loader.call, client: CLIENT
  @configuration = configuration
  @client = client
end

Public Instance Methods

call(arguments = []) click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 23
def call arguments = []
  client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
  client.separator "\nUSAGE:\n"
  collate
  arguments.empty? ? arguments : client.parse!(arguments)
end

Private Instance Methods

add_config() click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 36
def add_config
  client.on(
    "-c",
    "--config ACTION",
    %i[edit view],
    "Manage gem configuration. Actions: edit || view."
  ) do |action|
    configuration.action_config = action
  end
end
add_help() click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 70
def add_help
  client.on "-h", "--help", "Show this message." do
    configuration.action_help = true
  end
end
add_publish() click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 47
def add_publish
  client.on(
    "-P",
    "--publish VERSION",
    Versionaire::Version,
    "Tag and push milestone to remote repository."
  ) do |version|
    configuration.merge! action_publish: true, git_tag_version: version
  end
end
add_status() click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 58
def add_status
  client.on "-s", "--status", "Show project status." do
    configuration.action_status = true
  end
end
add_version() click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 64
def add_version
  client.on "-v", "--version", "Show gem version." do
    configuration.action_version = Identity::VERSION_LABEL
  end
end
collate(= private_methods.sort.grep(/add_/).each { |method| __send__ method }) click to toggle source
# File lib/milestoner/cli/parsers/core.rb, line 34
  def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }

  def add_config
    client.on(
      "-c",
      "--config ACTION",
      %i[edit view],
      "Manage gem configuration. Actions: edit || view."
    ) do |action|
      configuration.action_config = action
    end
  end

  def add_publish
    client.on(
      "-P",
      "--publish VERSION",
      Versionaire::Version,
      "Tag and push milestone to remote repository."
    ) do |version|
      configuration.merge! action_publish: true, git_tag_version: version
    end
  end

  def add_status
    client.on "-s", "--status", "Show project status." do
      configuration.action_status = true
    end
  end

  def add_version
    client.on "-v", "--version", "Show gem version." do
      configuration.action_version = Identity::VERSION_LABEL
    end
  end

  def add_help
    client.on "-h", "--help", "Show this message." do
      configuration.action_help = true
    end
  end
end