fix message and template send stdin issues

This commit is contained in:
Clément DOUIN 2023-12-19 15:36:56 +01:00
parent 73e1824a0d
commit c11f00d791
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
2 changed files with 5 additions and 9 deletions

View file

@ -36,16 +36,14 @@ impl MessageSendCommand {
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let msg = if is_tty || is_json {
let msg = if io::stdin().is_terminal() {
self.message.raw()
} else {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.collect::<Vec<String>>()
.collect::<Vec<_>>()
.join("\r\n")
};

View file

@ -39,17 +39,15 @@ impl TemplateSendCommand {
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let tpl = if is_tty || is_json {
let tpl = if io::stdin().is_terminal() {
self.template.raw()
} else {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.collect::<Vec<String>>()
.join("\r\n")
.collect::<Vec<_>>()
.join("\n")
};
#[allow(unused_mut)]