lib/hanami/cli/commands/command.rb in hanami-1.3.5 vs lib/hanami/cli/commands/command.rb in hanami-2.0.0.alpha1
- old
+ new
@@ -1,25 +1,23 @@
-require 'hanami'
-require 'hanami/environment'
-require 'hanami/components'
-require 'dry/cli/command'
-require 'hanami/cli/commands/project'
-require 'hanami/cli/commands/templates'
-require 'concurrent'
-require 'hanami/utils/files'
-require 'erb'
+# frozen_string_literal: true
+require "hanami"
+require "hanami/cli/command"
+require "concurrent"
+require "hanami/utils/files"
+require "erb"
+
module Hanami
# Hanami CLI
#
# @since 1.1.0
class CLI
module Commands
# Abstract command
#
# @since 1.1.0
- class Command < Dry::CLI::Command
+ class Command < Hanami::CLI::Command
# @since 1.1.0
# @api private
def self.inherited(component)
super
@@ -70,34 +68,26 @@
# @api private
module InstanceMethods
# @since 1.1.0
# @api private
def call(**options)
- if self.class.requirements.any?
- environment = Hanami::Environment.new(options)
- environment.require_project_environment
-
- requirements.resolved('environment', environment)
- requirements.resolve(self.class.requirements)
-
- options = environment.to_options.merge(options)
- end
-
- super(**options)
+ # FIXME: merge ENV vars (like HANAMI_ENV) into **options
+ super(options)
rescue StandardError => e
warn e.message
warn e.backtrace.join("\n\t")
exit(1)
end
end
# @since 1.1.0
# @api private
- def initialize(out: $stdout, files: Utils::Files)
- @out = out
- @files = files
- @templates = Templates.new(self.class)
+ def initialize(command_name:, out: $stdout, files: Utils::Files)
+ super(command_name: command_name)
+
+ @out = out
+ @files = files
end
private
# Template renderer
@@ -105,11 +95,11 @@
# @since 1.1.0
# @api private
class Renderer
# @since 1.1.0
# @api private
- TRIM_MODE = "-".freeze
+ TRIM_MODE = "-"
# @since 1.1.0
# @api private
def initialize
freeze
@@ -122,11 +112,11 @@
end
end
# @since 1.1.0
# @api private
- SAY_FORMATTER = "%<operation>12s %<path>s\n".freeze
+ SAY_FORMATTER = "%<operation>12s %<path>s\n"
# @since 1.1.0
# @api private
attr_reader :out
@@ -163,16 +153,18 @@
end
# @since 1.1.0
# @api private
def project
- Project
+ # FIXME: is this still useful?
+ raise "it used to be implemented as Project"
end
# @since 1.1.0
# @api private
def requirements
- Hanami::Components
+ # FIXME: require components via the new Hanami::Container
+ raise "it used to be implemented as Hanami::Components"
end
end
end
end
end