mirror of https://github.com/djcb/mu.git
mu: add --uncooked option for mu extract
To avoid replacing spaces with dashes Fixes #2434.
This commit is contained in:
parent
5c037f7579
commit
ff08731298
|
@ -51,6 +51,11 @@ directory.
|
|||
overwrite existing files with the same name; by default overwriting is not
|
||||
allowed.
|
||||
|
||||
** -u,--uncooked
|
||||
by default, ~mu~ transforms the attachment filenames a bit (such as by replacing
|
||||
spaces by dashes); with this option, leave that to the minimum for creating
|
||||
a legal filename in the target directory.
|
||||
|
||||
** --play
|
||||
Try to 'play' (open) the attachment with the default application for the
|
||||
particular file type. On MacOS, this uses the *open* program, on other platforms
|
||||
|
|
|
@ -33,8 +33,12 @@ save_part(const Message::Part& part, size_t idx, const Options& opts)
|
|||
const auto tdir{opts.extract.targetdir};
|
||||
return tdir.empty() ? tdir : tdir + G_DIR_SEPARATOR_S;
|
||||
});
|
||||
|
||||
/* 'uncooked' isn't really _raw_; it means only doing some _minimal_
|
||||
* cooking */
|
||||
const auto path{targetdir +
|
||||
part.cooked_filename().value_or(format("part-%zu", idx))};
|
||||
part.cooked_filename(opts.extract.uncooked)
|
||||
.value_or(format("part-%zu", idx))};
|
||||
|
||||
if (auto&& res{part.to_file(path, opts.extract.overwrite)}; !res)
|
||||
return Err(res.error());
|
||||
|
|
|
@ -222,6 +222,8 @@ sub_extract(CLI::App& sub, Options& opts)
|
|||
sub.add_option("message", opts.extract.message,
|
||||
"Path to message file")->required()
|
||||
->type_name("<message-path>");
|
||||
sub.add_flag("--uncooked,-u", opts.extract.uncooked,
|
||||
"Avoid massaging extracted file-names");
|
||||
sub.add_option("filename-rx", opts.extract.filename_rx,
|
||||
"Regular expression for files to save")
|
||||
->type_name("<filename-rx>")
|
||||
|
|
|
@ -126,6 +126,8 @@ struct Options {
|
|||
bool overwrite; /**< overwrite same-named files */
|
||||
bool play; /**< try to 'play' attachment */
|
||||
std::string filename_rx; /**< Filename rx to save */
|
||||
bool uncooked{}; /**< Whether to avoid massaging
|
||||
* output filename */
|
||||
} extract;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue