class Rubysmith::CLI::Shell

The main Command Line Interface (CLI) object.

Constants

PROCESSORS

Attributes

parser[R]
processors[R]

Public Class Methods

new(parser: Parsers::Assembler.new, processors: PROCESSORS) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 17
def initialize parser: Parsers::Assembler.new, processors: PROCESSORS
  @parser = parser
  @processors = processors
end

Public Instance Methods

call(arguments = []) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 22
def call arguments = []
  parse arguments

  case options
    in config: Symbol => action then process_config action
    in build_minimum: true then process_build :build_minimum, options
    in build: then process_build :build_maximum, options
    in version: String => version then puts version
    else usage
  end
end

Private Instance Methods

options(= parser.to_h) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 51
    def options = parser.to_h

    def usage = puts(parser.to_s)
  end
end
parse(arguments = []) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 38
def parse arguments = []
  parser.call arguments
rescue StandardError => error
  puts error.message
end
process_build(kind, settings) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 46
def process_build kind, settings
  processors.fetch(kind).call settings.transform_keys(build: :project_name)
                                      .merge(now: Time.now)
end
process_config(action) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 44
      def process_config(action) = processors.fetch(:config).call(action)

      def process_build kind, settings
        processors.fetch(kind).call settings.transform_keys(build: :project_name)
                                            .merge(now: Time.now)
      end

      def options = parser.to_h

      def usage = puts(parser.to_s)
    end
  end
end
usage(= puts(parser.to_s)) click to toggle source
# File lib/rubysmith/cli/shell.rb, line 53
  def usage = puts(parser.to_s)
end