Skip to content

Commit 0b6e8c8

Browse files
authored
Ask the user if they want to force a non-upgrade (#21)
Prompts the user asking if they want to force a non-upgrade if they're in interactive mode, instead of requiring the --force flag. Fixes #16.
1 parent fb73f37 commit 0b6e8c8

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

brainframe/cli/commands/update.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ def update():
2525
existing_version = version.parse(existing_version_str)
2626
requested_version = version.parse(requested_version_str)
2727

28-
if not args.force:
28+
force_downgrade = False
29+
if args.noninteractive:
30+
# Use the --force flag to decide if downgrades are allowed
31+
force_downgrade = args.force
32+
else:
33+
# Ask the user if downgrades should be allowed
34+
if existing_version >= requested_version:
35+
force_downgrade = print_utils.ask_yes_no(
36+
"update.ask-force-downgrade"
37+
)
38+
39+
if not force_downgrade:
40+
# Fail if the requested version is not an upgrade
2941
if existing_version == requested_version:
3042
print_utils.fail_translate(
3143
"update.version-already-installed",

brainframe/cli/translations/update.en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ en:
2020
than the currently installed version, BrainFrame:%{existing_version}. We
2121
don't recommend downgrading BrainFrame for data integrity reasons. This
2222
request will be ignored. You can force a downgrade using the --force flag."
23+
ask-force-downgrade: "BrainFrame:%{requested_version} does not appear to
24+
be a newer version then the current version, BrainFrame:%{existing_version}.
25+
Downgrading BrainFrame is not officially supported and may lead to data loss.
26+
Are you sure you want to continue?"

0 commit comments

Comments
 (0)