mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
bin/tau: fix viewing events
This commit is contained in:
@@ -59,7 +59,7 @@ connect to in the p2p network.
|
||||
in config file:
|
||||
|
||||
## Connection slots
|
||||
outbound_connections=5
|
||||
outbound_connections=8
|
||||
|
||||
## Seed nodes to connect to
|
||||
seeds=["127.0.0.1:11001"]
|
||||
@@ -139,6 +139,3 @@ $ # comments
|
||||
$ tau comments 1 # list comments
|
||||
$ tau comments 3 "new comment" # add new comment
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ mod util;
|
||||
mod view;
|
||||
|
||||
use cli::CliTauSubCommands;
|
||||
use primitives::TaskInfo;
|
||||
use primitives::{TaskEvent, TaskInfo};
|
||||
use util::{desc_in_editor, CONFIG_FILE, CONFIG_FILE_CONTENTS};
|
||||
use view::{comments_as_string, events_as_string, print_list_of_task, print_task_info};
|
||||
use view::{comments_as_string, print_list_of_task, print_task_info};
|
||||
|
||||
async fn start(mut options: cli::CliTau) -> Result<()> {
|
||||
let rpc_addr = &format!("tcp://{}", &options.rpc_listen.clone());
|
||||
@@ -71,7 +71,9 @@ async fn start(mut options: cli::CliTau) -> Result<()> {
|
||||
None => {
|
||||
let task = jsonrpc::get_task_by_id(rpc_addr, id).await?;
|
||||
let taskinfo: TaskInfo = serde_json::from_value(task.clone())?;
|
||||
let state = events_as_string(taskinfo.events);
|
||||
let default_event =
|
||||
TaskEvent { action: "open".to_string(), timestamp: primitives::Timestamp(0) };
|
||||
let state = &taskinfo.events.last().unwrap_or(&default_event).action;
|
||||
println!("Task {}: {}", id, state);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -112,13 +112,17 @@ pub fn comments_as_string(comments: Vec<Comment>) -> String {
|
||||
comments_str.push_str(&comment.to_string());
|
||||
comments_str.push('\n');
|
||||
}
|
||||
comments_str.pop();
|
||||
comments_str
|
||||
}
|
||||
|
||||
pub fn events_as_string(events: Vec<TaskEvent>) -> String {
|
||||
let mut events_str = String::new();
|
||||
for event in events {
|
||||
events_str.push_str(&event.to_string());
|
||||
events_str.push_str("State changed to ");
|
||||
events_str.push_str(&event.action.to_string());
|
||||
events_str.push_str(" at ");
|
||||
events_str.push_str(×tamp_to_date(event.timestamp.0, "datetime"));
|
||||
events_str.push('\n');
|
||||
}
|
||||
events_str
|
||||
|
||||
Reference in New Issue
Block a user