···13use std::str::FromStr as _;
14use std::{env::current_dir, io::Read};
15use task::ParsedLink;
16-use workspace::{Id, TaskIdentifier, Workspace};
1718//use smol;
19//use iocraft::prelude::*;
···46 Init,
47 /// Creates a new task, automatically assigning it a unique identifider and persisting
48 Push {
00000000000000000049 /// Whether to open $EDITOR to edit the content of the task. The first line if the
50 /// resulting file will be the task's title. The body follows the title after two newlines,
51 /// similr to the format of a commit message.
···236 let var_name = match cli.command {
237 Commands::Init => command_init(dir),
238 Commands::Push { edit, body, title } => command_push(dir, edit, body, title),
0239 Commands::List { all, count } => command_list(dir, all, count),
240 Commands::Swap => command_swap(dir),
241 Commands::Show {
···283 Workspace::init(dir)
284}
285286-fn command_push(dir: PathBuf, edit: bool, body: Option<String>, title: Title) -> Result<()> {
287- let workspace = Workspace::from_path(dir)?;
0000288 let mut title = if let Some(title) = title.title {
289 title
290 } else if let Some(title) = title.title_simple {
···309 }
310 let task = workspace.new_task(title, body)?;
311 workspace.handle_metadata(&task, None)?;
000000312 workspace.push_task(task)
000000313}
314315fn command_list(dir: PathBuf, all: bool, count: usize) -> Result<()> {
···13use std::str::FromStr as _;
14use std::{env::current_dir, io::Read};
15use task::ParsedLink;
16+use workspace::{Id, Task, TaskIdentifier, Workspace};
1718//use smol;
19//use iocraft::prelude::*;
···46 Init,
47 /// Creates a new task, automatically assigning it a unique identifider and persisting
48 Push {
49+ /// Whether to open $EDITOR to edit the content of the task. The first line if the
50+ /// resulting file will be the task's title. The body follows the title after two newlines,
51+ /// similr to the format of a commit message.
52+ #[arg(short = 'e', default_value_t = false)]
53+ edit: bool,
54+55+ /// The body of the task. It may be specified as either a string using quotes or the
56+ /// special character '-' to read from stdin.
57+ #[arg(short = 'b')]
58+ body: Option<String>,
59+60+ /// The title of the task as a raw string. It mus be proceeded by two dashes (--).
61+ #[command(flatten)]
62+ title: Title,
63+ },
64+ /// Creates a new task just like `push`, but instead of putting it at the top of the stack, it
65+ /// puts it at the bottom
66+ Append {
67 /// Whether to open $EDITOR to edit the content of the task. The first line if the
68 /// resulting file will be the task's title. The body follows the title after two newlines,
69 /// similr to the format of a commit message.
···254 let var_name = match cli.command {
255 Commands::Init => command_init(dir),
256 Commands::Push { edit, body, title } => command_push(dir, edit, body, title),
257+ Commands::Append { edit, body, title } => command_append(dir, edit, body, title),
258 Commands::List { all, count } => command_list(dir, all, count),
259 Commands::Swap => command_swap(dir),
260 Commands::Show {
···302 Workspace::init(dir)
303}
304305+fn create_task(
306+ workspace: &mut Workspace,
307+ edit: bool,
308+ body: Option<String>,
309+ title: Title,
310+) -> Result<Task> {
311 let mut title = if let Some(title) = title.title {
312 title
313 } else if let Some(title) = title.title_simple {
···332 }
333 let task = workspace.new_task(title, body)?;
334 workspace.handle_metadata(&task, None)?;
335+ Ok(task)
336+}
337+338+fn command_push(dir: PathBuf, edit: bool, body: Option<String>, title: Title) -> Result<()> {
339+ let mut workspace = Workspace::from_path(dir)?;
340+ let task = create_task(&mut workspace, edit, body, title)?;
341 workspace.push_task(task)
342+}
343+344+fn command_append(dir: PathBuf, edit: bool, body: Option<String>, title: Title) -> Result<()> {
345+ let mut workspace = Workspace::from_path(dir)?;
346+ let task = create_task(&mut workspace, edit, body, title)?;
347+ workspace.append_task(task)
348}
349350fn command_list(dir: PathBuf, all: bool, count: usize) -> Result<()> {