Skip to content

Commit acc9898

Browse files
integration: add --yes to skip interactive prompts in commitment rebuild (#20291)
## Summary Adds a `--yes` flag to `integration commitment rebuild` that bypasses both interactive prompts, making the command suitable for scripted/background use. ## Prompts bypassed 1. **"commitment history is enabled. Rebuild with history? (yes/no)"** — `--yes` automatically proceeds with history enabled 2. **"remove files?"** — `--yes` skips the `PromptUserBeforeDelete` confirmation in `DeleteStateSnapshots` ## Usage ```bash ./build/bin/integration commitment rebuild --datadir=... --chain=... --yes ``` ## Changes - `flags.go`: add `yes bool` variable + `withYes()` helper - `commitment.go`: register `withYes` on `cmdCommitmentRebuild`; use `yes` to skip both prompts
1 parent 1d0ad36 commit acc9898

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

cmd/integration/commands/commitment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func init() {
115115
withIntegrityChecks(cmdCommitmentRebuild)
116116
withHeimdall(cmdCommitmentRebuild)
117117
withChaosMonkey(cmdCommitmentRebuild)
118+
withYes(cmdCommitmentRebuild)
118119
withClearCommitment(cmdCommitmentRebuild)
119120
withResume(cmdCommitmentRebuild)
120121
withNoHistory(cmdCommitmentRebuild)
@@ -325,7 +326,7 @@ func commitmentRebuild(db kv.TemporalRwDB, ctx context.Context, logger log.Logge
325326
// --no-history explicitly requested: skip history regeneration entirely
326327
withHistory = false
327328
} else if commitmentHistoryEnabled {
328-
if clearCommitment || resume {
329+
if clearCommitment || resume || yes {
329330
withHistory = true
330331
} else {
331332
fmt.Print("commitment history is enabled. Rebuild with history? (yes/no): ")
@@ -348,7 +349,7 @@ func commitmentRebuild(db kv.TemporalRwDB, ctx context.Context, logger log.Logge
348349
if err := app.DeleteStateSnapshots(app.DeleteStateSnapshotsArgs{
349350
Dirs: dirs,
350351
RemoveLatest: false,
351-
PromptUserBeforeDelete: true,
352+
PromptUserBeforeDelete: !yes,
352353
DryRun: false,
353354
StepRange: "0-999999",
354355
OnlyDomain: !withHistory,

cmd/integration/commands/flags.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ import (
2626
)
2727

2828
var (
29-
chaindata string
30-
databaseVerbosity int
31-
referenceChaindata string
32-
block, pruneTo, unwind uint64
33-
unwindEvery uint64
34-
batchSizeStr string
35-
domain string
36-
reset, noCommit, squeeze bool
37-
bucket string
38-
datadirCli, toChaindata string
39-
migration string
40-
integrityFast, integritySlow bool
41-
file string
42-
HeimdallURL string
43-
txtrace bool // Whether to trace the execution (should only be used together with `block`)
44-
chain string // Which chain to use (mainnet, sepolia, etc.)
45-
outputCsvFile string
29+
chaindata string
30+
databaseVerbosity int
31+
referenceChaindata string
32+
block, pruneTo, unwind uint64
33+
unwindEvery uint64
34+
batchSizeStr string
35+
domain string
36+
reset, noCommit, squeeze, yes bool
37+
bucket string
38+
datadirCli, toChaindata string
39+
migration string
40+
integrityFast, integritySlow bool
41+
file string
42+
HeimdallURL string
43+
txtrace bool // Whether to trace the execution (should only be used together with `block`)
44+
chain string // Which chain to use (mainnet, sepolia, etc.)
45+
outputCsvFile string
4646

4747
startTxNum uint64
4848

@@ -112,6 +112,10 @@ func withReset(cmd *cobra.Command) {
112112
cmd.Flags().BoolVar(&reset, "reset", false, "reset given stage")
113113
}
114114

115+
func withYes(cmd *cobra.Command) {
116+
cmd.Flags().BoolVar(&yes, "yes", false, "skip interactive prompts (for non-interactive/background use)")
117+
}
118+
115119
func withSqueeze(cmd *cobra.Command) {
116120
cmd.Flags().BoolVar(&squeeze, "squeeze", true, "use offset-pointers from commitment.kv to account.kv")
117121
}

0 commit comments

Comments
 (0)