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.)
Since
ConfigListrequires aDatabase, which can itself only be opened from a path, it's not possible to do the equivalent ofnotmuch config get database.pathin 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:
in place of currently needing:
or similar. (Or worse, make assumptions like 'it's always at ~/mail', or '$MAILDIR is always set', or erroneously point at the
.notmuchdir which is only used ifdatabase.mail_rootis unset, etc.)