Sha256: 220969d7ff98fdefadf30593bc5b8e2411a467b0b9aaa1c1be615b116278ee14
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true module Milestoner module CLI # The main Command Line Interface (CLI) object. class Shell ACTIONS = { config: Actions::Config.new, publish: Actions::Publish.new, status: Actions::Status.new }.freeze def initialize parser: Parsers::Assembler.new, actions: ACTIONS, container: Container @parser = parser @actions = actions @container = container end def call arguments = [] perform parser.call(arguments) rescue OptionParser::ParseError, Error => 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_publish: true then publish configuration in action_status: true then status in action_version: String => version then logger.info version in action_help: then usage else usage end end def config(action) = actions.fetch(__method__).call(action) def publish(configuration) = actions.fetch(__method__).call(configuration) def status = actions.fetch(__method__).call def usage = logger.unknown { parser.to_s } def logger = container[__method__] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
milestoner-12.0.2 | lib/milestoner/cli/shell.rb |
milestoner-12.0.1 | lib/milestoner/cli/shell.rb |
milestoner-12.0.0 | lib/milestoner/cli/shell.rb |