Skip to content

feat (bug-fix): enhance CLI scaffolding with new options and tests#5

Merged
MUKE-coder merged 6 commits intoMUKE-coder:mainfrom
mosespace:grit/cmd_features
Mar 27, 2026
Merged

feat (bug-fix): enhance CLI scaffolding with new options and tests#5
MUKE-coder merged 6 commits intoMUKE-coder:mainfrom
mosespace:grit/cmd_features

Conversation

@mosespace
Copy link
Copy Markdown
Contributor

This pull request adds support for scaffolding new Grit projects directly into the current directory (in-place), with safety checks and a --force flag to allow operation in non-empty directories. It updates the CLI, internal scaffolding logic, documentation, and adds comprehensive tests for the new behaviors.

CLI and User Experience Improvements:

  • Added support for grit new . and grit new ./ to scaffold into the current directory, inferring the project name from the folder. Introduced --here (in-place) and --force flags for controlling directory usage and overwriting. The CLI now automatically detects when the current directory matches the project name and scaffolds in place. [1] [2] [3] [4] [5]

Scaffolding Logic Enhancements:

  • Refactored directory resolution and validation logic with new helper functions resolveScaffoldRoot and ensureTargetDirectory, handling in-place scaffolding and force-overwrite semantics. Updated both multi-app and single-app scaffolding flows to use this logic. [1] [2] [3]

User Feedback:

  • Improved post-scaffold instructions: omits the cd step if scaffolding was done in-place.

Testing:

  • Added extensive unit tests for the new in-place and force behaviors, covering edge cases like directory emptiness and error handling.

Documentation:

  • Updated the README.md to document the new in-place scaffolding commands and usage tips. [1] [2]

@mosespace
Copy link
Copy Markdown
Contributor Author

mosespace commented Mar 27, 2026

with this 544577b; it fixes

Improvement: Flags Now Properly Bypass Prompts

This PR fixes an issue where CLI flags were not respected during project scaffolding.

Previously, running:

grit new my-saas --triple --vite

would still prompt the user to manually select options that were already provided via flags.

Previous Behavior

  • Flags like --triple and --vite were ignored during the prompt phase
  • Users were asked to re-select options interactively
  • This defeated the purpose of using flags for a quicker setup

Updated Behavior (This PR)

With this change, flags are now properly honored:

  • Any options passed via flags automatically skip the corresponding prompts
  • The command behaves as expected for a faster, more streamlined workflow
  • Enables a more non-interactive CLI experience, especially useful for scripting and automation

Result

This aligns the CLI behavior with standard expectations flags now act as true shortcuts, improving overall developer experience and efficiency.

@mosespace mosespace changed the title feat: enhance CLI scaffolding with new options and tests feat (bug-fix): enhance CLI scaffolding with new options and tests Mar 27, 2026
@MUKE-coder
Copy link
Copy Markdown
Owner

Thanks for this PR @mosespace — great work on the helper functions, tests, and --force flag. Really clean implementation.

Good news: The core functionality (grit new . and flag-skip for --triple --vite) is now on main as of ec55691. We fixed it from the same user feedback.

What this PR still adds that we'd love to merge:

  1. --force flag for non-empty directories — this is a nice safety feature we don't have yet
  2. resolveScaffoldRoot() and ensureTargetDirectory() helper functions — cleaner than our inline approach
  3. Unit tests for in-place and force behaviors
  4. README updates and grit new ./ support
  5. Skip cd step in success message when in-place

Could you rebase this PR on the latest main? There will be conflicts in cmd/grit/main.go and internal/scaffold/scaffold.go since both were modified. After the rebase we can merge the --force flag, helper functions, and tests.

git fetch origin
git rebase origin/main
# Resolve conflicts, keeping the helper function approach
git push --force-with-lease

Thanks for contributing!

@mosespace
Copy link
Copy Markdown
Contributor Author

with scaffolding
image

without with scaffolding
image

@mosespace
Copy link
Copy Markdown
Contributor Author

@MUKE-coder Please confirm if no more conflicts!.

@MUKE-coder
Copy link
Copy Markdown
Owner

Hey @mosespace — quick rebase guide to get this PR up to date with main:

# 1. Make sure you're on your PR branch
git checkout grit/cmd_features

# 2. Fetch the latest changes from origin
git fetch origin

# 3. Rebase your branch on top of the latest main
git rebase origin/main

You'll likely get conflicts in these 2 files:

  • cmd/grit/main.go
  • internal/scaffold/scaffold.go

For cmd/grit/main.go: Keep your --force flag and the filepath.Clean(projectArg) == "." check, but note that the anyFlagSet logic has changed on main — we now check archFlag != "" and frontendFlag != "" directly instead of cmd.Flags().Changed(). Merge both approaches.

For internal/scaffold/scaffold.go: Keep your resolveScaffoldRoot() and ensureTargetDirectory() helper functions — they're cleaner than our inline approach. The Options struct already has InPlace bool on main, so just add your Force bool field.

# 4. After resolving conflicts in each file:
git add cmd/grit/main.go internal/scaffold/scaffold.go
git rebase --continue

# 5. Verify it builds
go build ./cmd/grit/

# 6. Run tests
go test ./internal/scaffold/ -count=1

# 7. Force push (safe since it's your branch)
git push --force-with-lease

If the rebase gets messy, you can always abort and start over:

git rebase --abort

Let me know if you hit any issues!

@MUKE-coder MUKE-coder merged commit af14998 into MUKE-coder:main Mar 27, 2026
MUKE-coder added a commit that referenced this pull request Mar 27, 2026
Post-merge cleanup from PR #5:
- Replaced cmd.Flags().Changed() prompt check with simpler archFlag/frontendFlag
  direct value checks, which are more reliable across all flag sources (PreRunE
  sets these from shorthand bool flags like --single, --triple, --vite)
- Added missing Force bool field to Options struct (lost during merge)
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