Skip to content

Commit

Permalink
#107 - add command listhashtags to display hashtags used in tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMarkelov committed Feb 13, 2025
1 parent fe8e3f2 commit 2b5014d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 30 deletions.
82 changes: 56 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ttdl"
version = "4.8.0"
version = "4.9.0"
authors = ["Vladimir Markelov <vmatroskin@gmail.com>"]
edition = "2021"
keywords = ["todotxt", "terminal", "cli", "todo", "tasks"]
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,15 @@ Commands:
- prepend - inserts a new text at the beginning of the selected todos (space between old text and new one is added automatically);
- start - activate todo's timer;
- stop - stop todo's timer and update time spent on the todo;
- stats - display todo statistics: total number of todos, done and overdue ones, spent time, and detailed statistics grouped by project and context.
- postpone - push task's due date (modifies only incomplete tasks with due date defined), argument is the number of days/weeks/months/years to push the date in format: single digit and d/w/m/y without a space between them
- stats - display todo statistics: total number of todos, done and overdue ones, spent time, and detailed statistics grouped by project and context;
- postpone - push task's due date (modifies only incomplete tasks with due date defined), argument is the number of days/weeks/months/years to push the date in format: single digit and d/w/m/y without a space between them;
- listprojects - show list of all project tags. Filters used by "list" are supported;
- listcontexts - show list of all context tags. Filters used by "list" are supported;
- listhashtags - show list of all hashtags. Filters used by "list" are supported.

Most of the commands can be abbreviated. Please refer to built-in TTDL help to get a list of full command names and their aliases.

All commands(except `listcontexts` and `listprojects`) skip hidden tasks by default. To include hidden tasks, use `--hidden` option. See section [tags](#tags) for details.
All commands(except `listhashtags`, `listcontexts` and `listprojects`) skip hidden tasks by default. To include hidden tasks, use `--hidden` option. See section [tags](#tags) for details.

NOTE: `done` moves a recurrent todo's due date to the next one, but it does not check if the new due date is in the future (it is by design). So, if a monthly task is 2 months overdue, you have to execute `ttdl done ID` two times to push it to the incoming month or manually set a new due date with the command `ttdl edit ID --set-due=YYYY-MM-DD`.

Expand Down
8 changes: 8 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
ttdl (4.9.0) unstable; urgency=medium

* New command "listhashtags" (with shortcuts "listhash" and "lh"). The
command prints out all hashtags used in tasks. It is similar to
existing "lp" and "lc" which list projects and contexts respectively.

-- Vladimir Markelov <vmatroskin@gmail.com> Wed, 12 Feb 2025 18:42:32 -0800

ttdl (4.8.0) unstable; urgency=medium

* New special dates are available when setting due and other dates. The new
Expand Down
2 changes: 2 additions & 0 deletions src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum RunMode {
Postpone,
ListProjects,
ListContexts,
ListHashtags,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -237,6 +238,7 @@ fn str_to_mode(s: &str) -> RunMode {
"postpone" => RunMode::Postpone,
"lp" | "listproj" | "listprojects" => RunMode::ListProjects,
"lc" | "listcon" | "listcontexts" => RunMode::ListContexts,
"lh" | "listhash" | "listhashtags" => RunMode::ListHashtags,
_ => RunMode::None,
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,19 @@ fn task_list_contexts(stdout: &mut StandardStream, tasks: &todo::TaskSlice, conf
Ok(())
}

fn task_list_hashtags(stdout: &mut StandardStream, tasks: &todo::TaskSlice, conf: &conf::Conf) -> io::Result<()> {
let mut conf = conf.clone();
conf.show_hidden = true;
let todos = filter_tasks(tasks, &conf);
// no tsort::sort() here since multiple contexts in one task
// would mess up the alphabetical output sort

for item in collect_unique_items(tasks, &todos, |task| &task.hashtags) {
writeln!(stdout, "{item}")?;
}
Ok(())
}

fn main() {
let args: Vec<String> = env::args().collect();

Expand Down Expand Up @@ -972,6 +985,7 @@ fn main() {
conf::RunMode::Postpone => task_postpone(&mut stdout, &mut tasks, &conf),
conf::RunMode::ListProjects => task_list_projects(&mut stdout, &tasks, &conf),
conf::RunMode::ListContexts => task_list_contexts(&mut stdout, &tasks, &conf),
conf::RunMode::ListHashtags => task_list_hashtags(&mut stdout, &tasks, &conf),
_ => Ok(()),
};
if let Err(e) = err {
Expand Down

0 comments on commit 2b5014d

Please sign in to comment.