浏览代码

fix message and template send stdin issues

Clément DOUIN 1 年之前
父节点
当前提交
c11f00d791
共有 2 个文件被更改,包括 5 次插入9 次删除
  1. 2 4
      src/email/message/command/send.rs
  2. 3 5
      src/email/message/template/command/send.rs

+ 2 - 4
src/email/message/command/send.rs

@@ -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")
         };
 

+ 3 - 5
src/email/message/template/command/send.rs

@@ -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)]