Sha256: 0ded87bc321f642205d19dcccb3dbff8e6dde1ef203ff1b3f63e36c10d574795

Contents?: true

Size: 1.37 KB

Versions: 29

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'eac_cli/docopt/doc_builder'
require 'eac_cli/docopt/runner_context_replacement'
require 'eac_cli/runner'
require 'eac_ruby_utils/console/docopt_runner'

module EacCli
  module Docopt
    module RunnerExtension
      extend ::ActiveSupport::Concern

      included do
        prepend InstanceMethods
      end

      class << self
        def check(klass)
          return unless klass < ::EacRubyUtils::Console::DocoptRunner

          ::EacCli::Runner.alias_runner_class_methods(klass, '', 'eac_cli')
          ::EacCli::Runner.alias_runner_class_methods(klass, 'original', '')

          klass.include(self)
        end
      end

      module InstanceMethods
        def doc
          ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
        end

        def docopt_options
          super.merge(options_first: self.class.runner_definition.options_first?)
        end

        def runner_context
          @runner_context ||= ::EacCli::Docopt::RunnerContextReplacement.new(self)
        end
      end

      def extra_available_subcommands
        self.class.constants
            .map { |name| self.class.const_get(name) }
            .select { |c| c.instance_of? Class }
            .select { |c| c.included_modules.include?(::EacCli::Runner) }
            .map { |c| c.name.demodulize.underscore.dasherize }
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
avm-tools-0.98.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.97.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.96.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.16.3 lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.95.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.16.2 lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.16.1 lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.94.3 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.16.0 lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.94.2 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.94.1 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.15.1 lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.15.0 lib/eac_cli/docopt/runner_extension.rb
ehbrs-tools-0.20.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.94.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.14.0 lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.93.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
eac_cli-0.13.0 lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.92.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb
avm-tools-0.91.0 vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb