Sha256: 741db7341ea47da6a269715c7475ee97ffaa8421cd27b395382611755a7a2200

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 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/find"
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(ui: ui)
      end

      # A utility for bulk find-and-replace operations
      # @return [Actions::Find]
      def find
        Actions::Find.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
      # @return [Actions::Geny]
      def geny
        Actions::Geny.new(registry: command.registry)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geny-2.5.2 lib/geny/context/invoke.rb
geny-2.5.1 lib/geny/context/invoke.rb
geny-2.5.0 lib/geny/context/invoke.rb
geny-2.4.0 lib/geny/context/invoke.rb