Skip to content

Comments

feature/add --yes/--force flags and use click.confirm for prompts#228

Open
michaelj094 wants to merge 1 commit intoAffineFoundation:mainfrom
michaelj094:refactor/add-non-interactive-flag-use-click_confirm
Open

feature/add --yes/--force flags and use click.confirm for prompts#228
michaelj094 wants to merge 1 commit intoAffineFoundation:mainfrom
michaelj094:refactor/add-non-interactive-flag-use-click_confirm

Conversation

@michaelj094
Copy link

Add --yes / --force flags and convert interactive prompts to click.confirm for DB CLI

Summary

  • Replace blocking input() confirmation prompts in the database CLI with click.confirm().
  • Add non-interactive --yes (-y) and --force (-f) CLI options so destructive commands can run in CI or scripts.
  • Preserve interactive confirmation by default.
  • Replace affected print() outputs with click.echo() in the changed flows for better Click integration.

Motivation

Interactive input() prompts block automation and are hard to test. click.confirm() integrates with Click’s test harness (CliRunner) and improves predictability. Adding --yes / --force allows safe non-interactive operation for CI/automation while keeping interactive safeguards by default.

Files changed

  • affine/database/cli.py — primary changes:
    • Replaced input() with click.confirm().
    • Added yes: bool = False parameter to relevant async helper functions.
    • CLI wrappers now accept --yes/-y and --force/-f and forward the option to async helpers.
    • Switched several print() calls to click.echo() in the affected flows.

(No other files are intentionally modified by this PR.)

Behavior — before / after

  • Before: Commands like af db reset used input() and required typing yes to proceed.
  • After: af db reset prompts via click.confirm() by default, and af db reset -y or af db reset -f runs without prompting.

Interactive behavior remains the default to avoid accidental destructive actions.

Commands / Examples

  • Interactive (prompt):

    • af db reset
    • af db reset-table --table sample_results
    • af db blacklist clear
  • Non-interactive (no prompt):

    • af db reset -y
    • af db reset -f
    • af db reset-table --table sample_results -y
    • af db delete-samples-by-range --env agentgym:alfworld --start-task-id 0 --end-task-id 100 -y

Backward compatibility

  • Non-breaking: interactive behavior unchanged when no flags are supplied.
  • New flags are additive and optional.

Implementation notes

  • click.confirm() was chosen for compatibility with Click testing tooling.
  • Both --yes and --force are supported (--force is an alias).
  • The async helper functions accept a yes boolean so both sync CLI wrappers and tests can bypass prompts programmatically.

Safety & Security

  • Default remains interactive confirmation to prevent accidental destructive actions.
  • Document --yes usage in CI or admin scripts to make automation explicit.

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.

1 participant