Skip to content

Commit d1c35ca

Browse files
gwplclaude
andcommitted
Make disk resize an interactive option when not specified via flag
Per reviewer feedback, instead of a "nodisk" escape hatch in the confirmation prompt, make --disk/--no-disk a tri-state (True/False/None). When neither flag is passed, the user is asked interactively — consistent with how region, size, and image are already handled. The interactive question only appears when the new size has a different disk size. It defaults to "no" (skip disk resize) since disk resize is permanent and prevents future downsizing. Flow with no flags: Changes: Disk: 25 GB → 80 GB (+55 GB) Disk resize is PERMANENT and cannot be undone. Skipping disk resize keeps the option to downsize later. Resize disk too? [yes/no] (no): Flow with --no-disk: skips the question, shows "not resized" Flow with --disk: skips the question, proceeds with disk resize Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4559589 commit d1c35ca

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

dropkit/main.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,8 +3291,8 @@ def rename(
32913291
def resize(
32923292
droplet_name: str = typer.Argument(..., autocompletion=complete_droplet_or_snapshot_name),
32933293
size: str | None = typer.Option(None, "--size", "-s", help="New size slug (e.g., s-4vcpu-8gb)"),
3294-
disk: bool = typer.Option(
3295-
True, "--disk/--no-disk", help="Resize disk (permanent, default: True)"
3294+
disk: bool | None = typer.Option(
3295+
None, "--disk/--no-disk", help="Resize disk (permanent, asked interactively if omitted)"
32963296
),
32973297
):
32983298
"""
@@ -3494,12 +3494,13 @@ def resize(
34943494
else 0
34953495
)
34963496
disk_change = f"{current_disk} GB → {new_disk} GB"
3497-
if disk and disk_diff > 0:
3497+
if disk is False:
3498+
# User explicitly passed --no-disk
3499+
disk_change = f"{current_disk} GB (not resized)"
3500+
elif disk_diff > 0:
34983501
disk_change += f" [green](+{disk_diff} GB)[/green]"
3499-
elif disk and disk_diff < 0:
3502+
elif disk_diff < 0:
35003503
disk_change += f" [yellow]({disk_diff} GB)[/yellow]"
3501-
elif not disk:
3502-
disk_change = f"{current_disk} GB (not resized)"
35033504
changes_table.add_row("Disk:", disk_change)
35043505

35053506
# Price
@@ -3513,53 +3514,52 @@ def resize(
35133514

35143515
console.print(changes_table)
35153516

3517+
# If --disk/--no-disk was not explicitly passed, ask interactively
3518+
# when the new size has a different disk. This surfaces the
3519+
# permanent/irreversible nature of disk resize at decision time,
3520+
# consistent with how region/size/image are handled interactively.
3521+
if disk is None:
3522+
if isinstance(disk_diff, int) and disk_diff != 0:
3523+
console.print()
3524+
console.print(
3525+
"[bold yellow]Disk resize is PERMANENT and cannot be undone.[/bold yellow]"
3526+
)
3527+
console.print("[dim]Skipping disk resize keeps the option to downsize later.[/dim]")
3528+
disk_choice = Prompt.ask(
3529+
"[bold]Resize disk too?[/bold]",
3530+
choices=["yes", "no"],
3531+
default="no",
3532+
)
3533+
disk = disk_choice == "yes"
3534+
else:
3535+
# No disk change — default to True (no-op for disk)
3536+
disk = True
3537+
35163538
# Show warnings
35173539
console.print()
35183540
console.print(
3519-
"[bold yellow]⚠ WARNING: This operation will cause downtime (droplet will be powered off)[/bold yellow]"
3541+
"[bold yellow]⚠ WARNING: This operation will cause downtime "
3542+
"(droplet will be powered off)[/bold yellow]"
35203543
)
35213544

3522-
if disk:
3545+
if disk and isinstance(disk_diff, int) and disk_diff > 0:
35233546
console.print(
35243547
"[bold red]⚠ WARNING: Disk resize is PERMANENT and cannot be undone![/bold red]"
35253548
)
3526-
else:
3549+
elif not disk:
35273550
console.print(
3528-
"[dim]Note: Disk will NOT be resized. You can resize it later, but it's permanent.[/dim]"
3551+
"[dim]Note: Disk will NOT be resized. You can resize back down later.[/dim]"
35293552
)
35303553

3531-
# Confirmation — offer "nodisk" escape hatch when disk resize is
3532-
# planned and disk size would increase. This supports the common
3533-
# use case of temporarily scaling up CPU/RAM (e.g. for a heavy
3534-
# build or benchmark) and scaling back down later, which requires
3535-
# NOT resizing the disk (disk resize is permanent/irreversible and
3536-
# prevents future downsizing).
3554+
# Confirmation
35373555
console.print()
3538-
show_nodisk_option = disk and isinstance(disk_diff, int) and disk_diff > 0
3539-
3540-
if show_nodisk_option:
3541-
console.print(
3542-
"[dim]Tip: Answer 'nodisk' to skip disk resize "
3543-
"(keeps resize reversible for temporary scale-ups)[/dim]"
3544-
)
3545-
confirm = Prompt.ask(
3546-
"[yellow]Are you sure you want to resize this droplet?[/yellow]",
3547-
choices=["yes", "nodisk", "no"],
3548-
default="no",
3549-
)
3550-
else:
3551-
confirm = Prompt.ask(
3552-
"[yellow]Are you sure you want to resize this droplet?[/yellow]",
3553-
choices=["yes", "no"],
3554-
default="no",
3555-
)
3556+
confirm = Prompt.ask(
3557+
"[yellow]Are you sure you want to resize this droplet?[/yellow]",
3558+
choices=["yes", "no"],
3559+
default="no",
3560+
)
35563561

3557-
if confirm == "nodisk":
3558-
disk = False
3559-
console.print(
3560-
"[dim]Disk resize skipped — CPU/RAM only (you can resize back down later)[/dim]"
3561-
)
3562-
elif confirm != "yes":
3562+
if confirm != "yes":
35633563
console.print("[dim]Cancelled.[/dim]")
35643564
raise typer.Exit(0)
35653565

0 commit comments

Comments
 (0)