Sha256: 246ff7c1e192afe7b299d77cf783d2c20a5d85dd1fc8971ce7d320aa63604072
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Pragmater module CLI # The main Command Line Interface (CLI) object. class Shell ACTIONS = {config: Actions::Config.new, run: Actions::Run.new}.freeze def initialize parser: Parser.new, actions: ACTIONS, container: Container @parser = parser @actions = actions @container = container end def call arguments = [] perform parser.call(arguments) rescue OptionParser::ParseError => error logger.error { error.message } end private attr_reader :parser, :actions, :container def perform configuration case configuration in action_config: Symbol => action then config action in {action_insert: true} | {action_remove: true} then run configuration in action_version: true then logger.info Identity::VERSION_LABEL else usage end end def config(action) = actions.fetch(__method__).call(action) def run(configuration) = actions.fetch(__method__).call(configuration) def usage = logger.unknown(parser.to_s) def logger = container[__method__] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pragmater-10.0.1 | lib/pragmater/cli/shell.rb |
pragmater-10.0.0 | lib/pragmater/cli/shell.rb |