mu-move: add new move sub command
Add sub-command to move messages; add tests and docs. Fixes #157
This commit is contained in:
@ -47,6 +47,8 @@ public:
|
||||
using Id = Xapian::docid; /**< Id for a message in the store */
|
||||
static constexpr Id InvalidId = 0; /**< Invalid store id */
|
||||
using IdVec = std::vector<Id>; /**< Vector of document ids */
|
||||
using IdPathVec = std::vector<std::pair<Id, std::string>>;
|
||||
/**< vector of id, path pairs */
|
||||
|
||||
/**
|
||||
* Configuration options.
|
||||
@ -246,6 +248,15 @@ public:
|
||||
*/
|
||||
Option<Message> find_message(Id id) const;
|
||||
|
||||
/**
|
||||
* Find a message's docid based on its path
|
||||
*
|
||||
* @param path path to the message
|
||||
*
|
||||
* @return the docid or Nothing if not found
|
||||
*/
|
||||
Option<Id> find_message_id(const std::string& path) const;
|
||||
|
||||
/**
|
||||
* Find the messages for the given ids
|
||||
*
|
||||
@ -282,27 +293,35 @@ public:
|
||||
enum struct MoveOptions {
|
||||
None = 0, /**< Defaults */
|
||||
ChangeName = 1 << 0, /**< Change the name when moving */
|
||||
DupFlags = 1 << 1, /**< Update flags for duplicate messages too*/
|
||||
DupFlags = 1 << 1, /**< Update flags for duplicate messages too */
|
||||
DryRun = 1 << 2, /**< Don't really move, just determine target paths */
|
||||
};
|
||||
|
||||
/**
|
||||
* Move a message both in the filesystem and in the store. After a
|
||||
* successful move, the message is updated.
|
||||
* Move a message both in the filesystem and in the store. After a successful move, the
|
||||
* message is updated.
|
||||
*
|
||||
* @param id the id for some message
|
||||
* @param target_mdir the target maildir (if any)
|
||||
* @param new_flags new flags (if any)
|
||||
* @param change_name whether to change the name
|
||||
* @param opts move options
|
||||
*
|
||||
* @return Result, either an IdVec with ids for the moved
|
||||
* message(s) or some error. Note that in case of success at least one
|
||||
* message is returned, and only with MoveOptions::DupFlags can it be
|
||||
* more than one.
|
||||
* @return Result, either an IdPathVec with ids and paths for the moved message(s) or some
|
||||
* error. Note that in case of success at least one message is returned, and only with
|
||||
* MoveOptions::DupFlags can it be more than one.
|
||||
*/
|
||||
Result<IdVec> move_message(Store::Id id,
|
||||
Option<const std::string&> target_mdir = Nothing,
|
||||
Option<Flags> new_flags = Nothing,
|
||||
MoveOptions opts = MoveOptions::None);
|
||||
Result<IdPathVec> move_message(Store::Id id,
|
||||
Option<const std::string&> target_mdir = Nothing,
|
||||
Option<Flags> new_flags = Nothing,
|
||||
MoveOptions opts = MoveOptions::None);
|
||||
/**
|
||||
* Convert IdPathVec -> IdVec
|
||||
*
|
||||
* @param ips idpath vector
|
||||
*
|
||||
* @return vector of ids
|
||||
*/
|
||||
static IdVec id_vec(const IdPathVec& ips);
|
||||
|
||||
/**
|
||||
* Prototype for the ForEachMessageFunc
|
||||
|
||||
Reference in New Issue
Block a user