Sha256: 4a7a46799a1c482cd4f1167820b18fbaa6af0b559e99bb97a5ed76026ade66ab
Contents?: true
Size: 1.44 KB
Versions: 4
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true require "milestoner" module Rubysmith module CLI # The main Command Line Interface (CLI) object. class Shell ACTIONS = { config: Actions::Config.new, build: Actions::Build.new, publish: Actions::Publish.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, Milestoner::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_build: true then build configuration in action_publish: true then publish configuration in action_version: true then logger.info { specification.labeled_version } else usage end end def config(action) = actions.fetch(__method__).call(action) def build(configuration) = actions.fetch(__method__).call(configuration) def publish(configuration) = actions.fetch(__method__).call(configuration) def usage = logger.unknown(parser.to_s) def specification = container[__method__] def logger = container[__method__] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubysmith-2.0.2 | lib/rubysmith/cli/shell.rb |
rubysmith-2.0.1 | lib/rubysmith/cli/shell.rb |
rubysmith-2.0.0 | lib/rubysmith/cli/shell.rb |
rubysmith-1.3.0 | lib/rubysmith/cli/shell.rb |