Class: Hanami::CLI::Command

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/hanami/cli/command.rb

Overview

Base class for hanami CLI commands.

Since:

  • 2.0.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out:, err:, fs:, inflector:) ⇒ Command

Returns a new command.

This method does not need to be called directly when creating commands for the CLI. Commands are registered as classes, and the CLI framework will initialize the command when needed. This means that all parameters for #initialize should also be given default arguments. See new for the standard default arguments for all commands.

Parameters:

  • out (IO)

    I/O stream for standard command output

  • err (IO)

    I/O stream for comment errror output

  • fs (Hanami::CLI::Files)

    object for managing file system interactions

  • inflector (Dry::Inflector)

    inflector for any command-level inflections

See Also:

Since:

  • 2.0.0



49
50
51
52
53
54
55
# File 'lib/hanami/cli/command.rb', line 49

def initialize(out:, err:, fs:, inflector:)
  super()
  @out = out
  @err = err
  @fs = fs
  @inflector = inflector
end

Class Method Details

.new(out: $stdout, err: $stderr, fs: Hanami::CLI::Files.new(out: out), inflector: Dry::Inflector.new, **opts) ⇒ Object

Returns a new command.

Provides default values so they can be available to any subclasses defining their own #initialize methods.

See Also:

Since:

  • 2.1.0



23
24
25
26
27
28
29
30
31
# File 'lib/hanami/cli/command.rb', line 23

def self.new(
  out: $stdout,
  err: $stderr,
  fs: Hanami::CLI::Files.new(out: out),
  inflector: Dry::Inflector.new,
  **opts
)
  super
end