Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

TODO items are now numbered and can be deleted by number #5

Merged
merged 3 commits into from

2 participants

@seanirby

Since multiple items can be deleted from an argument(could be considered a feature), I made some changes so TODO items are displayed as a numbered list and can be deleted by number by providing an integer argument.

@jergason
Owner

Thanks, this looks neato.

@jergason jergason merged commit 6d129d4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 31 additions and 8 deletions.
  1. +10 −4 README.md
  2. +9 −3 badoop
  3. +12 −1 badoop-test.sh
View
14 README.md
@@ -25,12 +25,18 @@ Use it like so:
```bash
$ badoop Put badoop up on GitHub
$ badoop Finish blog post about badoop
+$ badoop Make brownies
$ badoop
- • put badoop up on GitHub
- • badoop Finish blog post about badoop
+ 1 put badoop up on GitHub
+ 2 Finish blog post about badoop
+ 3 Make brownies
$ badoop -d GitHub
$ badoop
- • badoop Finish blog post about badoop
+ 1 Finish blog post about badoop
+ 2 Make brownies
+$ badoop -d 1
+$ badoop
+ 1 Make brownies.
```
badoop can do four things.
@@ -38,7 +44,7 @@ badoop can do four things.
1. `badoop` with no arguments lists all todo items.
1. `badoop` followed by anything but a `-d` or `-h` will add that as a todo
item to your todo list.
-1. `badoop -d` deletes any todo items matching the arguments passed in next
+1. `badoop -d` Deletes todo items based on the provided argument. If the argument is a phrase then all todo items containing the phrase will be deleted. If the argument is an integer then only the todo item matching the integer will be deleted.
1. `badoop -h` prints out a help message.
It doesn't do anything with priorities or sorting or nesting or tagging or
View
12 badoop
@@ -20,7 +20,13 @@ function badone() {
# $@ is all the arguments passed in.
# not sure what d is. Flag to delete anything that matches?
if [[ -f "$BADOOP" ]]; then
- sed -i -e "/$@/d" "$BADOOP";
+ if [[ $@ = "" ]]; then
+ echo "Error: Please provide a keyword matching a word in the TODO item to be deleted or the number of the TODO item to be deleted"
+ elif [[ $@ = *[^0-9]* ]]; then
+ sed -i -e "/$@/d" "$BADOOP";
+ else
+ sed -i $@'d' "$BADOOP";
+ fi
fi
}
@@ -30,7 +36,7 @@ function badoop() {
if [[ $# == "0" ]]; then
if [[ -f "$BADOOP" ]]; then
- cat "$BADOOP";
+ cat -n "$BADOOP";
fi
elif [[ $1 == "-h" ]]; then
badoop_usage
@@ -40,7 +46,7 @@ function badoop() {
else
# adding a new todo
# $@ is a string containing all parameters
- echo "$@" >> "$BADOOP"
+ echo "$@" >> "$BADOOP"
fi
}
View
13 badoop-test.sh
@@ -34,7 +34,7 @@ it_prints_out_contents_of_todos_when_no_args_give() {
tear_down_test_file
}
-it_deletes_todos_matching_arguments() {
+it_deletes_todos_matching_word_arguments() {
set_up_test_file
echo "SOME STUFF" >> "$TODO"
$badoop -d SOME
@@ -42,3 +42,14 @@ it_deletes_todos_matching_arguments() {
test "$res" = ""
tear_down_test_file
}
+
+it_deletes_todo_matching_integer_argument(){
+ set_up_test_file
+ echo "FIRST TODO ENTRY" >> "$TODO"
+ echo "SECOND TODO ENTRY" >> "$TODO"
+ $badoop -d 2
+ $badoop -d 1
+ res="$($badoop)"
+ test "$res" = ""
+ tear_down_test_file
+}
Something went wrong with that request. Please try again.