feat(dev): add confirmation prompt to apply command
Add safety confirmation prompt to `core dev apply` before executing shell commands. This prevents accidental execution of destructive commands pasted from untrusted sources or generated by AI agents. Changes: - Add --yes/-y flag to skip confirmation prompt - Show warning and require explicit "y" confirmation before execution - Allow --dry-run to bypass confirmation (no actual execution) - Use existing cli.Confirm with Required() for mandatory response Usage: core dev apply --command="rm -rf ." # Prompts for confirmation core dev apply --command="..." --yes # Skips confirmation core dev apply --command="..." --dry-run # No execution, no prompt Closes #81 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f2bbb71875
commit
61bdb820e8
1 changed files with 14 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ var (
|
|||
applyDryRun bool
|
||||
applyPush bool
|
||||
applyContinue bool // Continue on error
|
||||
applyYes bool // Skip confirmation prompt
|
||||
)
|
||||
|
||||
// AddApplyCommand adds the 'apply' command to dev.
|
||||
|
|
@ -54,6 +55,7 @@ func AddApplyCommand(parent *cli.Command) {
|
|||
applyCmd.Flags().BoolVar(&applyDryRun, "dry-run", false, i18n.T("cmd.dev.apply.flag.dry_run"))
|
||||
applyCmd.Flags().BoolVar(&applyPush, "push", false, i18n.T("cmd.dev.apply.flag.push"))
|
||||
applyCmd.Flags().BoolVar(&applyContinue, "continue", false, i18n.T("cmd.dev.apply.flag.continue"))
|
||||
applyCmd.Flags().BoolVarP(&applyYes, "yes", "y", false, i18n.T("cmd.dev.apply.flag.yes"))
|
||||
|
||||
parent.AddCommand(applyCmd)
|
||||
}
|
||||
|
|
@ -101,6 +103,18 @@ func runApply() error {
|
|||
}
|
||||
cli.Blank()
|
||||
|
||||
// Require confirmation unless --yes or --dry-run
|
||||
if !applyYes && !applyDryRun {
|
||||
cli.Print("%s\n", warningStyle.Render(i18n.T("cmd.dev.apply.warning")))
|
||||
cli.Blank()
|
||||
|
||||
if !cli.Confirm(i18n.T("cmd.dev.apply.confirm"), cli.Required()) {
|
||||
cli.Print("%s\n", dimStyle.Render(i18n.T("cmd.dev.apply.cancelled")))
|
||||
return nil
|
||||
}
|
||||
cli.Blank()
|
||||
}
|
||||
|
||||
var succeeded, skipped, failed int
|
||||
|
||||
for _, repo := range targetRepos {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue