From 1b2d9d3847ca879e92455d06b433a212506a16f8 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 4 Dec 2024 23:18:15 +0200 Subject: [PATCH] mu-find: insist on --linksdir for links Fixes #2790. --- man/mu-find.1.org | 9 +++++---- mu/mu-cmd-find.cc | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/man/mu-find.1.org b/man/mu-find.1.org index 83e15e462..da3e4d710 100644 --- a/man/mu-find.1.org +++ b/man/mu-find.1.org @@ -127,15 +127,16 @@ Output results in the specified format. - The default is *plain*, i.e normal output with one line per message. - *links* outputs the results as a maildir with symbolic links to the found messages. This enables easy integration with mail-clients (see below for more - information). + information). This requires *--linksdir*. - *xml* formats the search results as XML. - *sexp* formats the search results as an s-expression as used in Lisp programming environments. ** --linksdir _dir_ and -c, --clearlinks -When using *--format=links*, output the results as a maildir with symbolic links to -the found messages. This enables easy integration with mail-clients (see below -for more information). *mu* will create the maildir if it does not exist yet. +When using *--format=links*, output the results as a maildir with symbolic links +to the found messages. This enables easy integration with mail-clients (see +below for more information). *mu* will create the maildir if it does not exist +yet. If you specify *--clearlinks*, existing symlinks will be cleared from the target directories; this allows for re-use of the same maildir. However, this option diff --git a/mu/mu-cmd-find.cc b/mu/mu-cmd-find.cc index 3853856d7..cd48e8fc0 100644 --- a/mu/mu-cmd-find.cc +++ b/mu/mu-cmd-find.cc @@ -164,6 +164,10 @@ get_query(const Store& store, const Options& opts) static Result prepare_links(const Options& opts) { + // XXX: can this be done as part of the option-parsing? + if (opts.find.linksdir.empty()) + return Err(Error::Code::InvalidArgument, "--linksdir is required"); + /* note, mu_maildir_mkdir simply ignores whatever part of the * mail dir already exists */ if (auto&& res = maildir_mkdir(opts.find.linksdir, 0700, true); !res)