Problem
The click.confirm → print [yellow]Cancelled[/yellow] → early-return pattern repeats 7 times across 5 CLI files (verified against upstream test):
if not click.confirm('...'):
console.print('[yellow]Cancelled[/yellow]')
return
Callsites (non-admin):
allways/cli/swap_commands/claim.py:41
allways/cli/swap_commands/collateral.py:88, 174
allways/cli/swap_commands/miner_commands.py:293
allways/cli/swap_commands/pair.py:188
allways/cli/swap_commands/swap.py:528, 698
Proposal
Add a small helper to allways/cli/swap_commands/helpers.py:
def require_confirmation(prompt: str, default: bool = False) -> bool:
"""Prompt for Y/N confirmation; print a cancel notice and return False on decline.
Returns True only when the user accepts. Callers should early-return on False.
"""
if not click.confirm(prompt, default=default):
console.print('[yellow]Cancelled[/yellow]')
return False
return True
Each callsite collapses to:
if not require_confirmation('...'):
return
Problem
The
click.confirm→ print[yellow]Cancelled[/yellow]→ early-return pattern repeats 7 times across 5 CLI files (verified against upstreamtest):Callsites (non-admin):
allways/cli/swap_commands/claim.py:41allways/cli/swap_commands/collateral.py:88, 174allways/cli/swap_commands/miner_commands.py:293allways/cli/swap_commands/pair.py:188allways/cli/swap_commands/swap.py:528, 698Proposal
Add a small helper to
allways/cli/swap_commands/helpers.py:Each callsite collapses to: