Sha256: 92696cfe65b6d57bbaac4d7660ba9a227b78668425d7d9d0842eb4b811a81e75
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Tocer module CLI # The main Command Line Interface (CLI) object. class Shell ACTIONS = {config: Actions::Config.new, insert: Actions::Insert.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 puts error.message end private attr_reader :parser, :actions, :container def perform configuration case configuration in action_config: Symbol => action then process_config action in action_insert: true then process_insert configuration in action_version: true then logger.info { "Tocer #{specification.version}" } else usage end end def process_config(action) = actions.fetch(:config).call(action) def process_insert(configuration) = actions.fetch(:insert).call(configuration) def usage = puts(parser.to_s) def specification = container[__method__] def logger = container[__method__] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tocer-13.1.0 | lib/tocer/cli/shell.rb |