mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 10:35:13 +00:00
use stdin to send message (#78)
This commit is contained in:
parent
08f10266e3
commit
4668d51476
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Send message via stdin [#78]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Table with subject containing `\r` or `\n`[#141]
|
- Table with subject containing `\r` or `\n`[#141]
|
||||||
|
@ -215,6 +219,7 @@ 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
|
||||||
|
[#78]: https://github.com/soywod/himalaya/issues/78
|
||||||
[#79]: https://github.com/soywod/himalaya/issues/79
|
[#79]: https://github.com/soywod/himalaya/issues/79
|
||||||
[#83]: https://github.com/soywod/himalaya/issues/83
|
[#83]: https://github.com/soywod/himalaya/issues/83
|
||||||
[#84]: https://github.com/soywod/himalaya/issues/84
|
[#84]: https://github.com/soywod/himalaya/issues/84
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
use clap;
|
use clap;
|
||||||
use error_chain::error_chain;
|
use error_chain::error_chain;
|
||||||
use log::{debug, error, trace};
|
use log::{debug, error, trace};
|
||||||
use std::{fs, ops::Deref};
|
use std::{
|
||||||
|
fs,
|
||||||
|
io::{self, BufRead},
|
||||||
|
ops::Deref,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
|
@ -590,7 +594,22 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||||
debug!("send command matched");
|
debug!("send command matched");
|
||||||
|
|
||||||
let mut imap_conn = ImapConnector::new(&app.account)?;
|
let mut imap_conn = ImapConnector::new(&app.account)?;
|
||||||
let msg = matches.value_of("message").unwrap();
|
|
||||||
|
let msg = if matches.is_present("message") {
|
||||||
|
matches
|
||||||
|
.value_of("message")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.replace("\r", "")
|
||||||
|
.replace("\n", "\r\n")
|
||||||
|
} else {
|
||||||
|
io::stdin()
|
||||||
|
.lock()
|
||||||
|
.lines()
|
||||||
|
.filter_map(|ln| ln.ok())
|
||||||
|
.map(|ln| ln.to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\r\n")
|
||||||
|
};
|
||||||
let msg = Msg::from(msg.to_string());
|
let msg = Msg::from(msg.to_string());
|
||||||
let msg = msg.to_sendable_msg()?;
|
let msg = msg.to_sendable_msg()?;
|
||||||
smtp::send(&app.account, &msg)?;
|
smtp::send(&app.account, &msg)?;
|
||||||
|
|
|
@ -148,7 +148,7 @@ function! himalaya#msg#forward()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! himalaya#msg#draft_save()
|
function! himalaya#msg#draft_save()
|
||||||
let s:draft = join(getline(1, "$"), "\r\n")
|
let s:draft = join(getline(1, "$"), "\n")
|
||||||
redraw | call s:log("Save draft [OK]")
|
redraw | call s:log("Save draft [OK]")
|
||||||
let &modified = 0
|
let &modified = 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in a new issue