Skip to content

Convenience method to get database for current env/config #33

@OJFord

Description

@OJFord

Since ConfigList requires a Database, which can itself only be opened from a path, it's not possible to do the equivalent of notmuch config get database.path in order to find the database to open.

It'd be nice to have a convenience method for this, either returning the path (without using ConfigList) or for opening the db too.

Looking at the C API I think there's nothing for it but to shell out for it. Other than inspecting the env var and default search path of course, but then that's subject to break if notmuch itself changes or adds to it.

I'm imagining something like:

let db_path = notmuch::get_current_database_path();

in place of currently needing:

let mut db_path = String::from_utf8(
    Command::new("notmuch")
        .args(&["config", "get", "database.path"])
        .output()?
        .stdout,
)?;
db_path = db_path.trim().to_string();

or similar. (Or worse, make assumptions like 'it's always at ~/mail', or '$MAILDIR is always set', or erroneously point at the .notmuch dir which is only used if database.mail_root is unset, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions