Sha256: 4e19512461ef7543c508590d76b6c53d3a38a950f62de92b3d34d803c8497d41

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'hamster'

require_relative '../model'
require_relative 'mixins/options'
require_relative 'mixins/appliables'

module Lino
  module Builders
    class Subcommand
      include Mixins::Options
      include Mixins::Appliables

      class << self
        def for_subcommand(subcommand)
          Builders::Subcommand.new(subcommand:)
        end
      end

      def initialize(state)
        @subcommand = state[:subcommand]
        @options = Hamster::Vector.new(state[:options] || [])
      end

      def build(option_separator, option_quoting, option_placement)
        Model::Subcommand.new(
          @subcommand,
          options: build_options(
            option_separator,
            option_quoting,
            option_placement
          )
        )
      end

      private

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

      def state
        {
          subcommand: @subcommand,
          options: @options
        }
      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/subcommand.rb
lino-4.2.0.pre.1 lib/lino/builders/subcommand.rb
lino-4.1.0 lib/lino/builders/subcommand.rb
lino-4.1.0.pre.2 lib/lino/builders/subcommand.rb
lino-4.1.0.pre.1 lib/lino/builders/subcommand.rb