Sha256: da1f66a542e8c7649cc59e8d700582893db9e74faf14eb43951070b493ba7d2f

Contents?: true

Size: 936 Bytes

Versions: 52

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

require 'eac_cli/runner'
require 'eac_ruby_utils/core_ext'

module EacCli
  module RunnerWith
    module Help
      require_sub __FILE__
      common_concern do
        include ::EacCli::Runner

        runner_definition.alt do
          bool_opt '-h', '--help', 'Show help.', usage: true, required: true
          pos_arg :any_arg_with_help, repeat: true, optional: true, visible: false
        end

        set_callback :run, :before do
          help_run
        end
      end

      def help_run
        return unless show_help?

        puts help_text
        raise ::EacCli::Runner::Exit
      end

      def help_text
        r = ::EacCli::RunnerWith::Help::Builder.new(self.class.runner_definition).to_s
        r += help_extra_text if respond_to?(:help_extra_text)
        r
      end

      def show_help?
        parsed.help? && !if_respond(:run_subcommand?, false)
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 3 rubygems

Version Path
eac_cli-0.24.1 lib/eac_cli/runner_with/help.rb
avm-tools-0.113.2 sub/eac_cli/lib/eac_cli/runner_with/help.rb
eac_cli-0.24.0 lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.28.3 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.110.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.109.1 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.109.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.28.2 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
eac_cli-0.23.1 lib/eac_cli/runner_with/help.rb
avm-tools-0.108.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.28.1 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.107.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.28.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.106.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
eac_cli-0.23.0 lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.27.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.26.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
avm-tools-0.105.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.25.1 vendor/eac_cli/lib/eac_cli/runner_with/help.rb
ehbrs-tools-0.25.0 vendor/eac_cli/lib/eac_cli/runner_with/help.rb