Skip to content

feat: [#880] make commands accept multiple names#1498

Open
u-wlkjyy wants to merge 1 commit into
goravel:masterfrom
u-wlkjyy:feat/make-multiple-args
Open

feat: [#880] make commands accept multiple names#1498
u-wlkjyy wants to merge 1 commit into
goravel:masterfrom
u-wlkjyy:feat/make-multiple-args

Conversation

@u-wlkjyy

@u-wlkjyy u-wlkjyy commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

This implements #880 — allow make:* commands to accept multiple names so several files can be created in a single invocation, similar to mkdir:

./artisan make:controller UserController OrderController
./artisan make:model User Task
./artisan make:command CleanCache SyncUsers

Changes

  • support/console.MakeNames — new helper that returns every positional argument. When no argument is passed it returns a single empty name so NewMake still falls back to its interactive prompt, preserving the original single-name behavior.
  • Each make:* command (make:command, make:controller, make:middleware, make:request) — Handle now loops over MakeNames and creates one file per name. The per-name logic is extracted into a makeOne method so the loop stays small and readable.
  • Failure handling — if one name fails (e.g. the file already exists), the error is reported via ctx.Error but the remaining names are still processed, mirroring mkdir. This also makes the command more script-friendly.

Backward compatibility

Fully backward compatible:

  • make:controller UserController → unchanged (single name).
  • make:controller (no arg) → still prompts interactively.
  • No contract changes; only command Handle behavior.

Tests

Added multi-name tests for every command:

  • TestMakeCommand_MultipleNames
  • TestControllerMakeCommand_MultipleNames
  • TestControllerMakeCommand_MultipleNamesPartialFailure (verifies a failing name doesn't abort the rest)
  • TestMiddlewareMakeCommand_MultipleNames
  • TestRequestMakeCommand_MultipleNames

All existing tests still pass (existing Argument(0) expectations updated to Arguments()).

Note

While writing make:command multi-name tests I noticed a pre-existing issue unrelated to this change: make:command SomeName without a sub-directory (e.g. CleanCache vs Goravel/CleanCache) ends up with GetPackageName() == "commands" and registers &commands.CleanCache{}, which corrupts kernel.go. Existing single-name tests only cover the sub-directory form, so it wasn't caught. Happy to file a separate issue for that if useful — it's out of scope for #880.

Fixes #880.

Allow make:* commands (make:command, make:controller, make:middleware,
make:request) to create several files in a single invocation, e.g.
`make:controller UserController OrderController`.

- Add support/console.MakeNames helper that returns every positional
  argument, falling back to a single empty name so the interactive
  prompt still works when no argument is passed.
- Refactor each make command's Handle to loop over MakeNames and create
  one file per name, extracting the per-name logic into a makeOne method.
- A failure for one name (e.g. file already exists) is reported via
  ctx.Error but does not stop the remaining names, mirroring mkdir.
- Add multi-name tests for each command, including a partial-failure
  case for make:controller.
@u-wlkjyy u-wlkjyy requested a review from a team as a code owner June 18, 2026 13:59
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.48%. Comparing base (fff60dd) to head (0ba5947).
⚠️ Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
support/console/console.go 0.00% 5 Missing ⚠️
http/console/controller_make_command.go 87.50% 1 Missing ⚠️
http/console/middleware_make_command.go 87.50% 1 Missing ⚠️
http/console/request_make_command.go 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1498      +/-   ##
==========================================
+ Coverage   69.46%   69.48%   +0.01%     
==========================================
  Files         378      378              
  Lines       29726    29743      +17     
==========================================
+ Hits        20649    20666      +17     
- Misses       8124     8125       +1     
+ Partials      953      952       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl

hwbrzzl commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

It should be goravel/goravel#880

@hwbrzzl hwbrzzl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me. Could you cover other comments to implement this feature in this PR or another, and add a screenshot to confirm if this feature works in the PR description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants