Sha256: ce15c6e04897bf66857bf59c35d97097dcd859e03acda258df09158e43731126
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Rubysmith module CLI # The main Command Line Interface (CLI) object. class Shell ACTIONS = {config: Actions::Config.new, build: Actions::Build.new}.freeze def initialize parser: Parsers::Assembler.new, actions: ACTIONS, container: Container @parser = parser @actions = actions @container = container end def call arguments = [] case parse arguments in action_config: Symbol => action then config action in action_build: true then build in action_version: String => version then puts version else usage end end private attr_reader :parser, :actions, :container def parse arguments = [] parser.call arguments rescue StandardError => error puts error.message end def config(action) = actions.fetch(__method__).call(action) def build = actions.fetch(__method__).call def usage = logger.unknown(parser.to_s) def logger = container[__method__] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubysmith-0.13.0 | lib/rubysmith/cli/shell.rb |