← back to Cli Printing Press
feat(cli): add --force flag to generate command
96f0d5136990c22fb0a803037f32c890289b6704 · 2026-03-24 16:21:04 -0700 · Matt Van Horn
Removes existing output directory before generating when --force is set.
Prevents the need to manually rm -rf before regeneration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Files touched
Diff
commit 96f0d5136990c22fb0a803037f32c890289b6704
Author: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Date: Tue Mar 24 16:21:04 2026 -0700
feat(cli): add --force flag to generate command
Removes existing output directory before generating when --force is set.
Prevents the need to manually rm -rf before regeneration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---
internal/cli/root.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/internal/cli/root.go b/internal/cli/root.go
index 39d81e04..3ce4e519 100644
--- a/internal/cli/root.go
+++ b/internal/cli/root.go
@@ -43,6 +43,7 @@ func newGenerateCmd() *cobra.Command {
var outputDir string
var validate bool
var refresh bool
+ var force bool
cmd := &cobra.Command{
Use: "generate",
@@ -90,6 +91,11 @@ func newGenerateCmd() *cobra.Command {
if err != nil {
return fmt.Errorf("resolving output path: %w", err)
}
+ if force {
+ if err := os.RemoveAll(absOut); err != nil {
+ return fmt.Errorf("removing existing output dir: %w", err)
+ }
+ }
gen := generator.New(apiSpec, absOut)
if err := gen.Generate(); err != nil {
@@ -111,6 +117,7 @@ func newGenerateCmd() *cobra.Command {
cmd.Flags().StringVar(&outputDir, "output", "", "Output directory (default: <name>-cli)")
cmd.Flags().BoolVar(&validate, "validate", true, "Run quality gates on the generated project")
cmd.Flags().BoolVar(&refresh, "refresh", false, "Refresh cached remote spec before generating")
+ cmd.Flags().BoolVar(&force, "force", false, "Remove existing output directory before generating")
return cmd
}
← 7ca3e75b refactor(pipeline): rewrite seed templates as thin ce:plan p
·
back to Cli Printing Press
·
feat(generator): add CRUD aliases to generated CLI commands 5b3d281e →