tangled
alpha
login
or
join now
ngp.computer
/
tsk
A file-based task manager
0
fork
atom
overview
issues
pulls
pipelines
edit's tsk id arg is now optional
ngp.computer
1 year ago
b7c218df
6f57b846
+14
-9
2 changed files
expand all
collapse all
unified
split
src
main.rs
stack.rs
+11
-6
src/main.rs
···
60
60
61
61
Edit {
62
62
#[arg(short = 't')]
63
63
-
task_id: u32,
63
63
+
task_id: Option<u32>,
64
64
},
65
65
66
66
Completion {
67
67
#[arg(short = 's')]
68
68
shell: Shell,
69
69
},
70
70
-
71
70
/*
72
71
Drop {
73
72
#[arg(short = 't')]
···
161
160
workspace.swap_top().expect("swap to work");
162
161
}
163
162
164
164
-
fn command_edit(dir: PathBuf, id: u32) {
163
163
+
fn command_edit(dir: PathBuf, id: Option<u32>) {
165
164
let workspace = Workspace::from_path(dir).expect("Unable to find .tsk dir");
166
166
-
let mut task = workspace.task(id.into()).expect("To read task from disk");
167
167
-
let new_content =
168
168
-
open_editor(format!("{}\n\n{}", task.title.trim(), task.body.trim())).expect("Failed to edit file");
165
165
+
let mut task = if let Some(id) = id {
166
166
+
workspace.task(id.into()).expect("To read task from disk")
167
167
+
} else {
168
168
+
let mut stack = workspace.read_stack(Some(1)).expect("to read stack");
169
169
+
let stack_item = stack.pop().expect("No tasks on stack.");
170
170
+
workspace.task(stack_item.id).expect("couldn't read task")
171
171
+
};
172
172
+
let new_content = open_editor(format!("{}\n\n{}", task.title.trim(), task.body.trim()))
173
173
+
.expect("Failed to edit file");
169
174
if let Some((title, body)) = new_content.split_once("\n") {
170
175
task.title = title.to_string();
171
176
task.body = body.to_string();
+3
-3
src/stack.rs
···
18
18
const INDEXFILE: &str = "index";
19
19
20
20
pub(crate) struct StackItem {
21
21
-
id: Id,
22
22
-
title: String,
23
23
-
modify_time: SystemTime,
21
21
+
pub id: Id,
22
22
+
pub title: String,
23
23
+
pub modify_time: SystemTime,
24
24
}
25
25
26
26
impl Display for StackItem {