Sha256: d3bd091d12133aa362ae6f2fcb58234eb4a3848a914d93ba07a8f6776480b041

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require 'hamster'

require_relative 'mixins/appliables'
require_relative 'mixins/arguments'
require_relative 'mixins/environment_variables'
require_relative 'mixins/executor'
require_relative 'mixins/option_config'
require_relative 'mixins/options'
require_relative 'mixins/state_boundary'
require_relative 'mixins/subcommands'
require_relative 'mixins/validation'
require_relative 'mixins/working_directory'
require_relative '../model'

module Lino
  module Builders
    class CommandLine
      include Mixins::StateBoundary
      include Mixins::Arguments
      include Mixins::EnvironmentVariables
      include Mixins::OptionConfig
      include Mixins::Options
      include Mixins::Subcommands
      include Mixins::Executor
      include Mixins::WorkingDirectory
      include Mixins::Appliables
      include Mixins::Validation

      def initialize(state)
        @command = state[:command]
        super
      end

      def build
        Model::CommandLine.new(
          @command,
          state.merge(
            options: build_options(@option_separator, @option_quoting,
                                   @option_placement),
            subcommands: build_subcommands(@option_separator, @option_quoting,
                                           @option_placement)
          )
        )
      end

      protected

      def state
        super.merge(command: @command)
      end

      private

      def with(replacements)
        Builders::CommandLine.new(state.merge(replacements))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lino-4.2.0.pre.2 lib/lino/builders/command_line.rb
lino-4.2.0.pre.1 lib/lino/builders/command_line.rb
lino-4.1.0 lib/lino/builders/command_line.rb
lino-4.1.0.pre.2 lib/lino/builders/command_line.rb
lino-4.1.0.pre.1 lib/lino/builders/command_line.rb