Skip to content

Commit 63a8f4b

Browse files
Add --yes flag to pgroll baseline (#865)
Add a `--yes` flag to `pgroll baseline` to skip the prompt for confirmation.
1 parent 6c32984 commit 63a8f4b

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

cli-definition.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
"shorthand": "j",
2323
"description": "output in JSON format instead of YAML",
2424
"default": "false"
25+
},
26+
{
27+
"name": "yes",
28+
"shorthand": "y",
29+
"description": "skip confirmation prompt",
30+
"default": "false"
2531
}
2632
],
2733
"subcommands": [],

cmd/baseline.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
func baselineCmd() *cobra.Command {
1717
var useJSON bool
18+
var yes bool
1819

1920
baselineCmd := &cobra.Command{
2021
Use: "baseline <version> <target directory>",
@@ -39,11 +40,13 @@ func baselineCmd() *cobra.Command {
3940
return err
4041
}
4142

42-
// Prompt for confirmation
43-
fmt.Println("Creating a baseline migration will restart the migration history.")
44-
ok, _ := pterm.DefaultInteractiveConfirm.Show()
45-
if !ok {
46-
return nil
43+
// Prompt for confirmation unless --yes flag is set
44+
if !yes {
45+
fmt.Println("Creating a baseline migration will restart the migration history.")
46+
ok, _ := pterm.DefaultInteractiveConfirm.Show()
47+
if !ok {
48+
return nil
49+
}
4750
}
4851

4952
// Create a placeholder baseline migration
@@ -79,6 +82,7 @@ func baselineCmd() *cobra.Command {
7982
}
8083

8184
baselineCmd.Flags().BoolVarP(&useJSON, "json", "j", false, "output in JSON format instead of YAML")
85+
baselineCmd.Flags().BoolVarP(&yes, "yes", "y", false, "skip confirmation prompt")
8286

8387
return baselineCmd
8488
}

docs/cli/baseline.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ The command requires two arguments:
1919
1. `version` - The version name for the baseline (e.g., "01_initial_schema")
2020
2. `target directory` - The directory where the placeholder migration file will be written
2121

22-
The optional `--json` flag can be used to write the placeholder migration file in JSON format instead of YAML.
22+
Optional flags:
23+
- `--json` (`-j`) - Write the placeholder migration file in JSON format instead of YAML
24+
- `--yes` (`-y`) - Skip the confirmation prompt and proceed automatically
2325

2426
### How it works
2527

@@ -59,3 +61,9 @@ pgroll baseline 01_initial_schema ./migrations
5961
```
6062
pgroll baseline 01_initial_schema ./migrations --json
6163
```
64+
65+
#### Create a baseline without confirmation prompt
66+
67+
```
68+
pgroll baseline 01_initial_schema ./migrations --yes
69+
```

0 commit comments

Comments
 (0)