Skip to main content

Module config

Module config 

Source
Expand description

User settings, and the first-run download-folder prompt.

Settings live in the meta table of the same SQLite database as the downloads, so there is one file to back up, move or delete — no separate config file to drift out of sync with the download state.

The prompt has one hard rule: it must never block a script. It is shown only when both stdin and stderr are terminals and no machine-output flag was given. Everywhere else the platform’s Downloads folder is used silently, so rget URL behaves identically in a terminal and in a pipeline.

Structs§

ResolvedDir

Enums§

DirSource
How the effective download folder was decided — reported under --verbose and asserted in tests.

Constants§

DOWNLOAD_DIR_KEY
Settings key for the folder downloads land in when no --dir is given.

Functions§

ask
The prompt itself, with I/O injected so it can be tested without a terminal.
can_prompt
May we interrupt the user with a question?
normalise_dir
Turn user input into an absolute, usable directory: expand ~, resolve relative paths against the working directory, and create it if needed.
platform_download_dir
The platform’s Downloads folder.
prompt_for_download_dir
The first-run prompt. Returns None if we must not ask.
resolve_download_dir
Decide where this download should go.
save_download_dir
saved_download_dir
The saved default download folder, if the user has ever chosen one.
tildify
Render a path with ~ for display, so the prompt reads the way a person would write it.