From df5fceb4eaab4f1a3f337ae8f47317c6ac38b11e Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Mon, 25 Nov 2024 18:46:27 -0500 Subject: [PATCH 1/2] Only include --env options a single time Since we subclass this App::Command class as App::Generate::Command, the Environment module was being included twice --- lib/hanami/cli/commands/app/command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hanami/cli/commands/app/command.rb b/lib/hanami/cli/commands/app/command.rb index f59f144b..2d0d7513 100644 --- a/lib/hanami/cli/commands/app/command.rb +++ b/lib/hanami/cli/commands/app/command.rb @@ -51,7 +51,7 @@ def call(*args, **opts) # @api private def self.inherited(klass) super - klass.prepend(Environment) + klass.prepend(Environment) unless klass.ancestors.include?(Environment) end # Returns the Hanami app class. From 402542acc1ee23e0c16912536ab4b88e86d2bfcd Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Tue, 26 Nov 2024 21:42:43 -0500 Subject: [PATCH 2/2] Change place for fix to adding option --- lib/hanami/cli/commands/app/command.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/hanami/cli/commands/app/command.rb b/lib/hanami/cli/commands/app/command.rb index 2d0d7513..b9884626 100644 --- a/lib/hanami/cli/commands/app/command.rb +++ b/lib/hanami/cli/commands/app/command.rb @@ -30,7 +30,11 @@ module Environment # @since 2.2.0 # @api private def self.prepended(klass) - klass.option :env, desc: "App environment (development, test, production)", aliases: ["e"] + # This module is included each time the class is inherited from + # Without this check, the --env option is duplicated each time + unless klass.options.map(&:name).include?(:env) + klass.option :env, desc: "App environment (development, test, production)", aliases: ["e"] + end end # @since 2.0.0 @@ -51,7 +55,7 @@ def call(*args, **opts) # @api private def self.inherited(klass) super - klass.prepend(Environment) unless klass.ancestors.include?(Environment) + klass.prepend(Environment) end # Returns the Hanami app class.