Sha256: 903e5c080d30f386ec8ffb71dc98538e3ca89606a4c03ccb9de6ebe18191abe8

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'eac_cli/default_runner'
require 'eac_ruby_utils/core_ext'

module EacRubyBase0
  module Runner
    require_sub __FILE__
    common_concern do
      include ::EacCli::DefaultRunner
      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.'
        end
      end
    end

    def run
      on_speaker_node do |node|
        node.stderr = ::StringIO.new if options.fetch('--quiet')
        node.stdin = FailIfRequestInput.new if options.fetch('--no-input')
        if options.fetch('--version')
          show_version
        else
          run_with_subcommand
        end
      end
    end

    def application_version
      context(:application).version.to_s
    end

    def show_version
      out("#{application_version}\n")
    end

    class FailIfRequestInput
      enable_console_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
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
eac_ruby_base0-0.3.0 lib/eac_ruby_base0/runner.rb
avm-tools-0.76.1 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
avm-tools-0.76.0 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
avm-tools-0.75.1 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
avm-tools-0.75.0 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
avm-tools-0.74.1 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
avm-tools-0.74.0 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb
eac_ruby_base0-0.2.0 lib/eac_ruby_base0/runner.rb
avm-tools-0.73.0 vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb