Procházet zdrojové kódy

bin/tau: trim comments and rename some functions

Dastan-glitch před 3 roky
rodič
revize
e13e5b2d8d

+ 1 - 1
bin/tau/tau-cli/src/main.rs

@@ -305,7 +305,7 @@ async fn main() -> Result<()> {
                         exit(1)
                         exit(1)
                     }
                     }
 
 
-                    let res = tau.set_comment(task.id.into(), &comment.unwrap()).await?;
+                    let res = tau.set_comment(task.id.into(), comment.unwrap().trim()).await?;
                     if res {
                     if res {
                         let tsk = tau.get_task_by_id(task.id.into()).await?;
                         let tsk = tau.get_task_by_id(task.id.into()).await?;
                         print_task_info(tsk)?;
                         print_task_info(tsk)?;

+ 4 - 4
bin/tau/tau-cli/src/util.rs

@@ -30,7 +30,7 @@ use darkfi::{util::time::Timestamp, Result};
 
 
 use crate::{
 use crate::{
     primitives::TaskInfo,
     primitives::TaskInfo,
-    view::{helper_comments_func, helper_events_func, helper_taskinfo_func},
+    view::{comments_table, events_table, taskinfo_table},
 };
 };
 
 
 /// Parse due date (e.g. "1503" for 15 March) as i64 timestamp.
 /// Parse due date (e.g. "1503" for 15 March) as i64 timestamp.
@@ -75,9 +75,9 @@ pub fn prompt_text(task_info: TaskInfo, what: &str) -> Result<Option<String>> {
     writeln!(file, "\n# ------------------------ >8 ------------------------")?;
     writeln!(file, "\n# ------------------------ >8 ------------------------")?;
     writeln!(file, "# Do not modify or remove the line above.")?;
     writeln!(file, "# Do not modify or remove the line above.")?;
     writeln!(file, "# Everything below it will be ignored.")?;
     writeln!(file, "# Everything below it will be ignored.")?;
-    writeln!(file, "\n{}", helper_taskinfo_func(task_info.clone())?)?;
-    writeln!(file, "{}", helper_events_func(task_info.clone())?)?;
-    writeln!(file, "{}", helper_comments_func(task_info)?)?;
+    writeln!(file, "\n{}", taskinfo_table(task_info.clone())?)?;
+    writeln!(file, "{}", events_table(task_info.clone())?)?;
+    writeln!(file, "{}", comments_table(task_info)?)?;
 
 
     // Try $EDITOR, and if not, fallback to xdg-open.
     // Try $EDITOR, and if not, fallback to xdg-open.
     let editor_argv0 = match env::var("EDITOR") {
     let editor_argv0 = match env::var("EDITOR") {

+ 6 - 6
bin/tau/tau-cli/src/view.rs

@@ -122,7 +122,7 @@ pub fn print_task_list(tasks: Vec<TaskInfo>, ws: String) -> Result<()> {
     Ok(())
     Ok(())
 }
 }
 
 
-pub fn helper_taskinfo_func(taskinfo: TaskInfo) -> Result<Table> {
+pub fn taskinfo_table(taskinfo: TaskInfo) -> Result<Table> {
     let due = timestamp_to_date(taskinfo.due.unwrap_or(0), DateFormat::Date);
     let due = timestamp_to_date(taskinfo.due.unwrap_or(0), DateFormat::Date);
     let created_at = timestamp_to_date(taskinfo.created_at, DateFormat::DateTime);
     let created_at = timestamp_to_date(taskinfo.created_at, DateFormat::DateTime);
     let rank = if let Some(r) = taskinfo.rank { r.to_string() } else { "".to_string() };
     let rank = if let Some(r) = taskinfo.rank { r.to_string() } else { "".to_string() };
@@ -153,7 +153,7 @@ pub fn helper_taskinfo_func(taskinfo: TaskInfo) -> Result<Table> {
     Ok(table)
     Ok(table)
 }
 }
 
 
-pub fn helper_events_func(taskinfo: TaskInfo) -> Result<Table> {
+pub fn events_table(taskinfo: TaskInfo) -> Result<Table> {
     let (events, timestamps) = &events_as_string(taskinfo.events);
     let (events, timestamps) = &events_as_string(taskinfo.events);
     let mut events_table = table!([events, timestamps]);
     let mut events_table = table!([events, timestamps]);
     events_table.set_format(*FORMAT_NO_COLSEP);
     events_table.set_format(*FORMAT_NO_COLSEP);
@@ -161,7 +161,7 @@ pub fn helper_events_func(taskinfo: TaskInfo) -> Result<Table> {
     Ok(events_table)
     Ok(events_table)
 }
 }
 
 
-pub fn helper_comments_func(taskinfo: TaskInfo) -> Result<Table> {
+pub fn comments_table(taskinfo: TaskInfo) -> Result<Table> {
     let (events, timestamps) = &comments_as_string(taskinfo.events);
     let (events, timestamps) = &comments_as_string(taskinfo.events);
     let mut comments_table = table!([events, timestamps]);
     let mut comments_table = table!([events, timestamps]);
     comments_table.set_format(*FORMAT_NO_COLSEP);
     comments_table.set_format(*FORMAT_NO_COLSEP);
@@ -171,13 +171,13 @@ pub fn helper_comments_func(taskinfo: TaskInfo) -> Result<Table> {
 }
 }
 
 
 pub fn print_task_info(taskinfo: TaskInfo) -> Result<()> {
 pub fn print_task_info(taskinfo: TaskInfo) -> Result<()> {
-    let table = helper_taskinfo_func(taskinfo.clone())?;
+    let table = taskinfo_table(taskinfo.clone())?;
     table.printstd();
     table.printstd();
 
 
-    let events_table = helper_events_func(taskinfo.clone())?;
+    let events_table = events_table(taskinfo.clone())?;
     events_table.printstd();
     events_table.printstd();
 
 
-    let comments_table = helper_comments_func(taskinfo)?;
+    let comments_table = comments_table(taskinfo)?;
     comments_table.printstd();
     comments_table.printstd();
 
 
     Ok(())
     Ok(())