mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-20 15:11:11 +00:00
add --raw arg for read cmd (#79)
This commit is contained in:
parent
f26051685c
commit
570c67a2bb
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Wiki entry for Gmail users [#58]
|
- Wiki entry for Gmail users [#58]
|
||||||
- Info logs for copy/move/delete cmd + silent mode [#74]
|
- Info logs for copy/move/delete cmd + silent mode [#74]
|
||||||
|
- `--raw` arg for `read` cmd [#79]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -139,3 +140,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
[#71]: https://github.com/soywod/himalaya/issues/71
|
[#71]: https://github.com/soywod/himalaya/issues/71
|
||||||
[#74]: https://github.com/soywod/himalaya/issues/74
|
[#74]: https://github.com/soywod/himalaya/issues/74
|
||||||
[#75]: https://github.com/soywod/himalaya/issues/75
|
[#75]: https://github.com/soywod/himalaya/issues/75
|
||||||
|
[#79]: https://github.com/soywod/himalaya/issues/79
|
||||||
|
|
|
@ -21,6 +21,9 @@ error_chain! {
|
||||||
MsgModel(crate::msg::model::Error, crate::msg::model::ErrorKind);
|
MsgModel(crate::msg::model::Error, crate::msg::model::ErrorKind);
|
||||||
Smtp(crate::smtp::Error, crate::smtp::ErrorKind);
|
Smtp(crate::smtp::Error, crate::smtp::ErrorKind);
|
||||||
}
|
}
|
||||||
|
foreign_links {
|
||||||
|
Utf8(std::string::FromUtf8Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uid_arg<'a>() -> Arg<'a, 'a> {
|
pub fn uid_arg<'a>() -> Arg<'a, 'a> {
|
||||||
|
@ -106,6 +109,12 @@ pub fn msg_subcmds<'a>() -> Vec<App<'a, 'a>> {
|
||||||
.value_name("STRING")
|
.value_name("STRING")
|
||||||
.possible_values(&["plain", "html"])
|
.possible_values(&["plain", "html"])
|
||||||
.default_value("plain"),
|
.default_value("plain"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("raw")
|
||||||
|
.help("Reads raw message")
|
||||||
|
.long("raw")
|
||||||
|
.short("r"),
|
||||||
),
|
),
|
||||||
SubCommand::with_name("attachments")
|
SubCommand::with_name("attachments")
|
||||||
.aliases(&["attach", "att", "a"])
|
.aliases(&["attach", "att", "a"])
|
||||||
|
@ -230,10 +239,19 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||||
debug!("UID: {}", &uid);
|
debug!("UID: {}", &uid);
|
||||||
let mime = format!("text/{}", matches.value_of("mime-type").unwrap());
|
let mime = format!("text/{}", matches.value_of("mime-type").unwrap());
|
||||||
debug!("MIME: {}", &mime);
|
debug!("MIME: {}", &mime);
|
||||||
|
let raw = matches.is_present("raw");
|
||||||
|
debug!("Raw: {}", &raw);
|
||||||
|
|
||||||
let msg = imap_conn.read_msg(&mbox, &uid)?;
|
let msg = imap_conn.read_msg(&mbox, &uid)?;
|
||||||
|
if raw {
|
||||||
|
let msg = String::from_utf8(msg)
|
||||||
|
.chain_err(|| "Could not decode raw message as utf8 string")?;
|
||||||
|
let msg = msg.trim_end_matches("\n");
|
||||||
|
info!("{}", msg);
|
||||||
|
} else {
|
||||||
let msg = ReadableMsg::from_bytes(&mime, &msg)?;
|
let msg = ReadableMsg::from_bytes(&mime, &msg)?;
|
||||||
info!("{}", msg);
|
info!("{}", msg);
|
||||||
|
}
|
||||||
|
|
||||||
imap_conn.logout();
|
imap_conn.logout();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
Loading…
Reference in a new issue