Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search Command for Simplified Task Filtering #450

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ For example, to add a todo item, you can do:
```shell
todo.sh add "THING I NEED TO DO +project @context"
```
### `replace`
Replaces task on line ITEM# with UPDATED TODO.

```shell
todo.sh replace ITEM# "UPDATED TODO"
```
### `report`
Adds the number of open tasks and done tasks to report.txt.

```shell
todo.sh report
```

Read about all the possible commands in the [USAGE][USAGE] file.

Expand Down
19 changes: 19 additions & 0 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,13 @@ case $action in
fi
_addto "$TODO_FILE" "$input"
;;
"search")
shift
if [ -z "$1" ]; then
die "usage: $TODO_SH search [KEYWORD...]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searching without any KEYWORD doesn't make sense, and the usage contradicts the check above.

fi
grep -i "$@" "$TODO_FILE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike list, this doesn't do any numbering, formatting, and highlighting; this is just a plain grep?!

;;

"addm")
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
Expand All @@ -1098,6 +1105,18 @@ case $action in
shift
input=$*
fi
"renameproj")
if [ -z "$2" ]; then
die "usage: $TODO_SH renameproj +oldproject +newproject"
fi
old_project=$1
new_project=$2
if ! grep -q "$old_project" "$TODO_FILE"; then
die "Project $old_project not found in $TODO_FILE"
fi
sed -i.bak "s/$old_project/$new_project/g" "$TODO_FILE"
echo "Renamed project $old_project to $new_project in $TODO_FILE"
;;

# Set Internal Field Seperator as newline so we can
# loop across multiple lines
Expand Down