Add a way to unset the container runtime

Add a way to set the container runtime that Dangerzone uses back to the
default.
This commit is contained in:
Alex Pyrgiotis 2025-04-02 14:55:54 +03:00
parent 1a644e2506
commit 57667a96be
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA
2 changed files with 19 additions and 5 deletions

View file

@ -52,7 +52,11 @@ def print_header(s: str) -> None:
@click.option( @click.option(
"--set-container-runtime", "--set-container-runtime",
required=False, required=False,
help="The path to the container runtime you want to set in the settings", help=(
"The name or full path of the container runtime you want Dangerzone to use."
" You can specify the value 'default' if you want to take back your choice, and"
" let Dangerzone use the default runtime for this OS"
),
) )
@click.version_option(version=get_version(), message="%(version)s") @click.version_option(version=get_version(), message="%(version)s")
@errors.handle_document_errors @errors.handle_document_errors
@ -69,6 +73,12 @@ def cli_main(
display_banner() display_banner()
if set_container_runtime: if set_container_runtime:
settings = Settings() settings = Settings()
if set_container_runtime == "default":
settings.unset_custom_runtime()
click.echo(
"Instructed Dangerzone to use the default container runtime for this OS"
)
else:
container_runtime = settings.set_custom_runtime( container_runtime = settings.set_custom_runtime(
set_container_runtime, autosave=True set_container_runtime, autosave=True
) )

View file

@ -52,6 +52,10 @@ class Settings:
self.save() self.save()
return container_runtime return container_runtime
def unset_custom_runtime(self) -> None:
self.settings.pop("container_runtime")
self.save()
def get(self, key: str) -> Any: def get(self, key: str) -> Any:
return self.settings[key] return self.settings[key]