Sha256: f042f1e19319dc982faf2d97efb0e368e3e775aea4b726775d9d3187bdc59120

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

require "sod"

module Pragmater
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Dependencies[:defaults_path, :xdg_config, :specification]

      def initialize(context: Sod::Context, dsl: Sod, **)
        super(**)
        @context = context
        @dsl = dsl
      end

      def call(...) = cli.call(...)

      private

      attr_reader :context, :dsl

      def cli
        context = build_context

        dsl.new :pragmater, banner: specification.banner do
          on(Sod::Prefabs::Commands::Config, context:)
          on Commands::Insert
          on Commands::Remove
          on(Sod::Prefabs::Actions::Version, context:)
          on Sod::Prefabs::Actions::Help, self
        end
      end

      def build_context
        context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pragmater-16.0.0 lib/pragmater/cli/shell.rb