Skip to content

Commit a244eff

Browse files
committed
Add skip_recommendations option
1 parent 1023225 commit a244eff

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

lib/hanami/cli/command.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class Command < Dry::CLI::Command
2323
def self.new(
2424
out: $stdout,
2525
err: $stderr,
26-
fs: Hanami::CLI::Files.new,
26+
fs: Hanami::CLI::Files.new(skip_recommendations: opts[:skip_recommendations]),
2727
inflector: Dry::Inflector.new,
2828
**opts
2929
)
30-
super(out: out, err: err, fs: fs, inflector: inflector, **opts)
30+
super
3131
end
3232

3333
# Returns a new command.

lib/hanami/cli/files.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ module CLI
99
class Files < Dry::Files
1010
# @since 2.0.0
1111
# @api private
12-
def initialize(out: $stdout, **args)
12+
def initialize(out: $stdout, skip_recommendations: false, **args)
1313
super(**args)
1414
@out = out
15+
@skip_recommendations = skip_recommendations
1516
end
1617

1718
# @since 2.0.0
@@ -45,12 +46,14 @@ def chdir(path, &blk)
4546
# @since x.x.x
4647
# @api private
4748
def recommend(message)
48-
out.puts(" Recommendation: #{message}")
49+
unless skip_recommendations
50+
out.puts(" Recommendation: #{message}")
51+
end
4952
end
5053

5154
private
5255

53-
attr_reader :out
56+
attr_reader :out, :skip_recommendations
5457

5558
def updated(path)
5659
out.puts "Updated #{path}"

spec/unit/hanami/cli/commands/app/generate/operation_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,14 @@ def call
125125
expect(output).to include("Created slices/main/admin/books/add.rb")
126126
end
127127
end
128+
129+
context "with skip_recommendations: true" do
130+
let(:fs) { Hanami::CLI::Files.new(memory: true, out: out, skip_recommendations: true) }
131+
132+
it "generates an operation without a namespace, with a recommendation" do
133+
subject.call(name: "add_book")
134+
135+
expect(output).to_not include("Recommendation")
136+
end
137+
end
128138
end

0 commit comments

Comments
 (0)