Sha256: 2af55db428018c081c11c8022da78158aaf369c21b32f698cd7e7a3d86a6e2a9

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

require "pastel"
require "geny/context/base"
require "geny/actions/ui"
require "geny/actions/geny"
require "geny/actions/git"
require "geny/actions/shell"
require "geny/actions/files"
require "geny/actions/templates"

module Geny
  module Context
    # The `invoke` behavior for all commands is evaluated in
    # the context of this class. All methods that are defined
    # here are available inside `invoke`.
    class Invoke < Base
      # A utility for colored output
      # @return [Pastel]
      # @see https://github.com/piotrmurach/pastel
      def color
        Pastel.new(enabled: $stdout.tty?)
      end

      # A utility for printing messages to the console
      # @return [Actions::UI]
      def ui
        Actions::UI.new(color: color)
      end

      # A utility for interacting with files
      # @return [Actions::Files]
      def files
        Actions::Files.new
      end

      # A utility for running shell commands
      # @return [Actions::Shell]
      def shell
        Actions::Shell.new(ui: ui)
      end

      # A utility for interacting with git repositories
      # @return [Actions::Git]
      def git
        Actions::Git.new(shell: shell)
      end

      # A utility for rendering and copying templates
      # @return [Actions::Templates]
      def templates
        Actions::Templates.new(
          root: command.templates_path,
          view: View.new(command: command, locals: locals)
        )
      end

      # A utility for invoking other generators
      def geny
        Actions::Geny.new(registry: command.registry)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geny-2.0.0 lib/geny/context/invoke.rb
geny-1.0.1 lib/geny/context/invoke.rb
geny-1.0.0 lib/geny/context/invoke.rb