Skip to content

Commit ab65e6a

Browse files
committed
Never ask confirm with --yes
1 parent bd1c808 commit ab65e6a

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/dstack/_internal/cli/commands/apply.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ def _command(self, args: argparse.Namespace):
108108

109109
super()._command(args)
110110
if not args.yes and args.configuration_file == APPLY_STDIN_NAME:
111-
# FIXME: probably does not work since dstack apply can ask questions futher,
112-
# e.g. whether to terminate a resource on ctrl+c or not
113111
raise CLIError("Cannot read configuration from stdin if -y/--yes is not specified")
114112
if args.repo and args.no_repo:
115113
raise CLIError("Either --repo or --no-repo can be specified")

src/dstack/_internal/cli/services/configurators/fleet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _apply_plan(self, plan: FleetPlan, command_args: argparse.Namespace):
151151
time.sleep(LIVE_TABLE_PROVISION_INTERVAL_SECS)
152152
fleet = self.api.client.fleets.get(self.api.project, fleet.name)
153153
except KeyboardInterrupt:
154-
if confirm_ask("Delete the fleet before exiting?"):
154+
if not command_args.yes and confirm_ask("Delete the fleet before exiting?"):
155155
with console.status("Deleting fleet..."):
156156
self.api.client.fleets.delete(
157157
project_name=self.api.project, names=[fleet.name]

src/dstack/_internal/cli/services/configurators/gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def apply_configuration(
121121
time.sleep(LIVE_TABLE_PROVISION_INTERVAL_SECS)
122122
gateway = self.api.client.gateways.get(self.api.project, gateway.name)
123123
except KeyboardInterrupt:
124-
if confirm_ask("Delete the gateway before exiting?"):
124+
if not command_args.yes and confirm_ask("Delete the gateway before exiting?"):
125125
with console.status("Deleting gateway..."):
126126
self.api.client.gateways.delete(
127127
project_name=self.api.project,

src/dstack/_internal/cli/services/configurators/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ def apply_configuration(
218218
exit(1)
219219
except KeyboardInterrupt:
220220
try:
221-
if not confirm_ask(f"\nStop the run [code]{run.name}[/] before detaching?"):
221+
if command_args.yes or not confirm_ask(
222+
f"\nStop the run [code]{run.name}[/] before detaching?"
223+
):
222224
console.print("Detached")
223225
abort_at_exit = False
224226
return

src/dstack/_internal/cli/services/configurators/volume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def apply_configuration(
110110
time.sleep(LIVE_TABLE_PROVISION_INTERVAL_SECS)
111111
volume = self.api.client.volumes.get(self.api.project, volume.name)
112112
except KeyboardInterrupt:
113-
if confirm_ask("Delete the volume before exiting?"):
113+
if not command_args.yes and confirm_ask("Delete the volume before exiting?"):
114114
with console.status("Deleting volume..."):
115115
self.api.client.volumes.delete(
116116
project_name=self.api.project, names=[volume.name]

0 commit comments

Comments
 (0)