Sha256: 2c4c48206d64b7daf5b62f803ed01dd57d54390afd7b96d67b10dfe71c35868a

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require "sod"

module Pennyworth
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Import[: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 :pennyworth, banner: specification.banner do
          on(Sod::Prefabs::Commands::Config, context:)

          on "git_hub", "Render Alfred GitHub repositories script filter." do
            on Actions::GitHub::Organization
            on Actions::GitHub::User
          end

          on "htmx", "Render htmx script filters" do
            on Actions::HTMX::Example
            on Actions::HTMX::Extension
            on Actions::HTMX::Reference
          end

          on Actions::Encoding
          on Actions::HTTPStatus
          on Actions::Gem
          on Actions::StandardGem
          on Actions::StandardError
          on Actions::System::Error
          on Actions::System::Signal
          on Actions::Text
          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

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/cli/shell.rb
pennyworth-17.7.0 lib/pennyworth/cli/shell.rb
pennyworth-17.6.0 lib/pennyworth/cli/shell.rb
pennyworth-17.5.0 lib/pennyworth/cli/shell.rb