Sha256: 3a2df51234fc1ddf939264d5015433bec9fac5fe39651f2cf31487a9029810ff

Contents?: true

Size: 1.01 KB

Versions: 45

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module EacCli
  module Runner
    module InstanceMethods
      PARSER_ERROR_EXIT_CODE = 1

      def run_run
        parsed
        run_callbacks(:run) { run }
      rescue ::EacCli::Parser::Error => e
        run_parser_error(e)
      rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
        # Do nothing
      end

      def run_parser_error(error)
        $stderr.write("#{program_name}: #{error}\n")
        ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
      end

      def runner_context
        return @runner_context if @runner_context

        raise 'Context was required, but was not set yet'
      end

      def runner_context=(new_runner_context)
        @runner_context = new_runner_context
        @parsed = nil
      end

      def parsed
        @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
      end

      def program_name
        runner_context.if_present(&:program_name) || $PROGRAM_NAME
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 3 rubygems

Version Path
avm-tools-0.114.2 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.114.1 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.26.2 lib/eac_cli/runner/instance_methods.rb
avm-tools-0.114.0 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.26.1 lib/eac_cli/runner/instance_methods.rb
eac_cli-0.26.0 lib/eac_cli/runner/instance_methods.rb
avm-tools-0.113.6 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.113.5 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.25.0 lib/eac_cli/runner/instance_methods.rb
avm-tools-0.113.4 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.113.3 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.24.1 lib/eac_cli/runner/instance_methods.rb
avm-tools-0.113.2 sub/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.24.0 lib/eac_cli/runner/instance_methods.rb
ehbrs-tools-0.28.3 vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.110.0 vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.109.1 vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
avm-tools-0.109.0 vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
ehbrs-tools-0.28.2 vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
eac_cli-0.23.1 lib/eac_cli/runner/instance_methods.rb