Permalink
Browse files

Merge pull request #5 from seanirby/master

TODO items are now numbered and can be deleted by number
  • Loading branch information...
2 parents e9df080 + 0869119 commit 6d129d4a7e7fcfd7b8703613979a2031d9785954 @jergason committed Jan 9, 2013
Showing with 31 additions and 8 deletions.
  1. +10 −4 README.md
  2. +9 −3 badoop
  3. +12 −1 badoop-test.sh
View
@@ -25,20 +25,26 @@ 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.
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
@@ -34,11 +34,22 @@ 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
res="$($badoop)"
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
+}

0 comments on commit 6d129d4

Please sign in to comment.