Sha256: e3559f8621c2ba6d15e8fb9ae612033506c3b3d62655db2f0947ff038ba7d51d
Contents?: true
Size: 1.4 KB
Versions: 6
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require 'eac_cli/core_ext' require 'eac_cli/speaker' require 'eac_ruby_utils/speaker' module EacRubyBase0 module Runner require_sub __FILE__ enable_speaker common_concern do include ::EacCli::RunnerWith::Help include ::EacCli::RunnerWith::Subcommands runner_definition do bool_opt '-q', '--quiet', 'Quiet mode.' bool_opt '-I', '--no-input', 'Fail if a input is requested.' subcommands alt do bool_opt '-V', '--version', 'Show version.', usage: true, required: true end end end def run ::EacRubyUtils::Speaker.context.on(build_speaker) do if parsed.version? show_version else run_with_subcommand end end end def application_version runner_context.call(:application).version.to_s end def show_version out("#{application_version}\n") end class FailIfRequestInput enable_speaker %w[gets noecho].each do |method| define_method(method) do raise "Input method requested (\"#{method}\") and option --no-input is set" end end end private def build_speaker options = {} options[:err_out] = ::StringIO.new if parsed.quiet? options[:in_in] = FailIfRequestInput.new if parsed.no_input? ::EacCli::Speaker.new(options) end end end
Version data entries
6 entries across 6 versions & 2 rubygems