mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
fix message and template send stdin issues
This commit is contained in:
parent
73e1824a0d
commit
c11f00d791
|
@ -36,16 +36,14 @@ impl MessageSendCommand {
|
||||||
config.clone().into_account_configs(account, cache)?;
|
config.clone().into_account_configs(account, cache)?;
|
||||||
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
|
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
|
||||||
|
|
||||||
let is_tty = io::stdin().is_terminal();
|
let msg = if io::stdin().is_terminal() {
|
||||||
let is_json = printer.is_json();
|
|
||||||
let msg = if is_tty || is_json {
|
|
||||||
self.message.raw()
|
self.message.raw()
|
||||||
} else {
|
} else {
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.lock()
|
.lock()
|
||||||
.lines()
|
.lines()
|
||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\r\n")
|
.join("\r\n")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,15 @@ impl TemplateSendCommand {
|
||||||
config.clone().into_account_configs(account, cache)?;
|
config.clone().into_account_configs(account, cache)?;
|
||||||
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
|
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
|
||||||
|
|
||||||
let is_tty = io::stdin().is_terminal();
|
let tpl = if io::stdin().is_terminal() {
|
||||||
let is_json = printer.is_json();
|
|
||||||
let tpl = if is_tty || is_json {
|
|
||||||
self.template.raw()
|
self.template.raw()
|
||||||
} else {
|
} else {
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.lock()
|
.lock()
|
||||||
.lines()
|
.lines()
|
||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\r\n")
|
.join("\n")
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
|
|
Loading…
Reference in a new issue