Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OJFord opened this issue Jul 20, 2021 · 0 comments
Open

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

OJFord opened this issue Jul 20, 2021 · 0 comments

Comments

@OJFord
Copy link

OJFord commented Jul 20, 2021

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant