Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWillner committed Dec 28, 2017
1 parent 9386a2c commit ac630d0
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 138 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test: check
@shellcheck things.sh
@echo "Running unit tests..."
@bashcov shunit2 test/thingsTest.sh
@cat coverage/index.html
@cat coverage/index.html||true

check:
@type shellcheck >/dev/null 2>&1 || (echo "Run 'brew install shellcheck' first." >&2 ; exit 1)
Expand Down
93 changes: 48 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ COMMAND:
completed
cancelled
trashed
all (show all tasks)
nextish (show 5 next tasks that are also in someday projects)
old (show 5 tasks ordered by 'creationDate')
due (show 5 tasks ordered by due date)
waiting (show 5 tasks with the tag 'Waiting for' ordered by 'creationDate')
repeating (show 5 repeating tasks orderd by 'creationDate')
subtasks (show 5 subtasks)
projects (show 5 projects ordered by creation date)
headings (show 5 headings ordered by creation date)
notes (show 5 notes as <headings>: <notes> ordered by creation date)
csv (export all tasks as semicolon seperated values incl. notes and Excel friendly)
stat (provide an overview of the numbers of tasks)
search (provide details about specific tasks)
feedback (give feedback, request and propose changes)
all (show all tasks)
nextish (show 5 next tasks that are also in someday projects)
old (show 5 tasks ordered by 'creationDate')
due (show 5 tasks ordered by due date)
waiting (show 5 tasks with the tag 'Waiting for' ordered by 'creationDate')
repeating (show 5 repeating tasks orderd by 'creationDate')
subtasks (show 5 subtasks)
projects (show 5 projects ordered by creation date)
headings (show 5 headings ordered by creation date)
notes (show 5 notes as <headings>: <notes> ordered by creation date)
csv (export all tasks as semicolon seperated values incl. notes and Excel friendly)
stat (provide an overview of the numbers of tasks)
search (provide details about specific tasks)
feedback (give feedback, request and propose changes)
OPTIONS:
-l|--limitBy <number> Limit output by <number> of results
-w|--waitingTag <tag> Set waiting tag to <tag>
-o|--orderBy <column> Sort output by <column> (e.g. 'userModificationDate' or 'creationDate')
-s|--string <string> String <string> to search for
-l|--limitBy <number> Limit output by <number> of results
-w|--waitingTag <tag> Set waiting tag to <tag>
-o|--orderBy <column> Sort output by <column> (e.g. 'userModificationDate' or 'creationDate')
-s|--string <string> String <string> to search for
```

## Examples
Expand All @@ -63,33 +63,36 @@ OPTIONS:

```
$ things.sh stat
Inbox : 0
Today : 18
Upcoming : 195
Next : 8
Someday : 1146
Completed : 10981
Cancelled : 8506
Trashed : 500
Tasks : 1329
Subtasks : 15
Projects : 99
Repeating : 84
Nextish : 183
Headings : 24
Oldest : 2016-01-22
Farest : 2021-01-04
Days/Task : 39.0
Inbox : 0
Today : 18
Upcoming : 195
Next : 8
Someday : 1146
Completed : 10981
Cancelled : 8506
Trashed : 500
Tasks : 1329
Subtasks : 15
Projects : 99
Repeating : 84
Nextish : 183
Headings : 24
Oldest : 2016-01-22
Farest : 2021-01-04
Days/Task : 39.0
```



## CREDITS
* Author : Arjan van der Gaag (script for Things 2)
* Author : Alexander Willner (updates for Things 3, added many more commands, a lot refactoring)
* License : Whatever. Use at your own risk.
* https://github.com/AlexanderWillner/things.sh
* Author : Arjan van der Gaag (script for Things 2)
* Author : Alexander Willner (updates for Things 3, added many more commands, a lot refactoring)
* License : Whatever. Use at your own risk.
* Source : https://github.com/AlexanderWillner/things.sh
* https://github.com/koalaman/shellcheck
* https://dev.to/thiht/shell-scripts-matter
* https://google.github.io/styleguide/shell.xml
* https://kvz.io/blog/2013/11/21/bash-best-practices/
* https://github.com/progrium/bashstyle
189 changes: 97 additions & 92 deletions things.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#
# CREDITS
#
# Author : Arjan van der Gaag (script for Things 2)
# Author : Alexander Willner (updates for Things 3, added many more commands)
# Date : 2017-12-24
# License : Whatever. Use at your own risk.
# Source : https://github.com/AlexanderWillner/things.sh
# Author : Arjan van der Gaag (script for Things 2)
# Author : Alexander Willner (updates for Things 3, added many more commands)
# Date : 2017-12-24
# License : Whatever. Use at your own risk.
# Source : https://github.com/AlexanderWillner/things.sh
#

set -o errexit
Expand Down Expand Up @@ -71,26 +71,26 @@ COMMAND:
completed
cancelled
trashed
all (show all tasks)
nextish (show $limitBy next tasks that are also in someday projects)
old (show $limitBy tasks ordered by '$orderBy')
due (show $limitBy tasks ordered by due date)
waiting (show $limitBy tasks with the tag '$waitingTag' ordered by '$orderBy')
repeating (show $limitBy repeating tasks orderd by '$orderBy')
subtasks (show $limitBy subtasks)
projects (show $limitBy projects ordered by creation date)
headings (show $limitBy headings ordered by creation date)
notes (show $limitBy notes as <headings>: <notes> ordered by creation date)
csv (export all tasks as semicolon seperated values incl. notes and Excel friendly)
stat (provide an overview of the numbers of tasks)
search (provide details about specific tasks)
feedback (give feedback, request and propose changes)
all (show all tasks)
nextish (show $limitBy next tasks that are also in someday projects)
old (show $limitBy tasks ordered by '$orderBy')
due (show $limitBy tasks ordered by due date)
waiting (show $limitBy tasks with the tag '$waitingTag' ordered by '$orderBy')
repeating (show $limitBy repeating tasks orderd by '$orderBy')
subtasks (show $limitBy subtasks)
projects (show $limitBy projects ordered by creation date)
headings (show $limitBy headings ordered by creation date)
notes (show $limitBy notes as <headings>: <notes> ordered by creation date)
csv (export all tasks as semicolon seperated values incl. notes and Excel friendly)
stat (provide an overview of the numbers of tasks)
search (provide details about specific tasks)
feedback (give feedback, request and propose changes)
OPTIONS:
-l|--limitBy <number> Limit output by <number> of results
-w|--waitingTag <tag> Set waiting tag to <tag>
-o|--orderBy <column> Sort output by <column> (e.g. 'userModificationDate' or 'creationDate')
-s|--string <string> String <string> to search for
-l|--limitBy <number> Limit output by <number> of results
-w|--waitingTag <tag> Set waiting tag to <tag>
-o|--orderBy <column> Sort output by <column> (e.g. 'userModificationDate' or 'creationDate')
-s|--string <string> String <string> to search for
EOF
}

Expand Down Expand Up @@ -483,28 +483,28 @@ SQL


stat() {
echo -n "Inbox :"; inbox|wc -l
echo ""
echo -n "Today :"; today|wc -l
echo -n "Upcoming :"; upcoming|wc -l
echo -n "Next :"; next|wc -l
echo -n "Someday :"; someday|wc -l
echo ""
echo -n "Completed :"; completed|wc -l
echo -n "Cancelled :"; cancelled|wc -l
echo -n "Trashed :"; trashed|wc -l
echo ""
echo -n "Tasks :"; all|wc -l
echo -n "Subtasks :"; subtasks|wc -l
echo -n "Waiting :"; waiting|wc -l
echo -n "Projects :"; projects|wc -l
echo -n "Repeating :"; repeating|wc -l
echo -n "Nextish :"; nextish|wc -l
echo -n "Headings :"; headings|wc -l
echo -n "Inbox :"; inbox|wc -l
echo ""
echo -n "Today :"; today|wc -l
echo -n "Upcoming :"; upcoming|wc -l
echo -n "Next :"; next|wc -l
echo -n "Someday :"; someday|wc -l
echo ""
echo -n "Completed :"; completed|wc -l
echo -n "Cancelled :"; cancelled|wc -l
echo -n "Trashed :"; trashed|wc -l
echo ""
echo -n "Tasks :"; all|wc -l
echo -n "Subtasks :"; subtasks|wc -l
echo -n "Waiting :"; waiting|wc -l
echo -n "Projects :"; projects|wc -l
echo -n "Repeating :"; repeating|wc -l
echo -n "Nextish :"; nextish|wc -l
echo -n "Headings :"; headings|wc -l
echo ""
echo -n "Oldest : "; limitBy="1" old
echo -n "Farest : "; orderBy="startDate DESC" upcoming|tail -n1
echo -n "Days/Task : "; averageCompleteTime
echo -n "Oldest : "; limitBy="1" old
echo -n "Farest : "; orderBy="startDate DESC" upcoming|tail -n1
echo -n "Days/Task : "; averageCompleteTime
}

search() {
Expand Down Expand Up @@ -558,53 +558,58 @@ require_db() {
}

main() {
require_sqlite3
require_db

while [[ $# -gt 1 ]]; do
local key="$1"
case $key in
-l|--limitBy) limitBy="$2";shift;;
-w|--waitingTag) waitingTag="$2";shift;;
-o|--orderBy) orderBy="$2";shift;;
-s|--string) string="$2";shift;;
*) ;;
esac
shift
done
local command=${1:-}

if [[ -n $command ]]; then
case $1 in
inbox) inbox;;
today) today;;
upcoming) upcoming;;
next) next;;
anytime) anytime;;
someday) someday;;
all) all;;
nextish) nextish;;
completed) completed;;
old) old;;
due) due;;
repeating) repeating;;
subtasks) subtasks;;
projects) projects;;
headings) headings;;
cancelled) cancelled;;
trashed) trashed;;
waiting) waiting;;
notes) notes;;
csv) csv|awk '{gsub("<[^>]*>", "")}1'|iconv -c -f UTF-8 -t WINDOWS-1252//TRANSLIT;;
stat) limitBy="999999" stat;;
search) search;;
feedback) open https://github.com/AlexanderWillner/things.sh/issues/;;
*) usage;;
esac
else
usage;
fi
require_sqlite3
require_db

while [[ $# -gt 1 ]]; do
local key="$1"
case $key in
-l|--limitBy) limitBy="$2";shift;;
-w|--waitingTag) waitingTag="$2";shift;;
-o|--orderBy) orderBy="$2";shift;;
-s|--string) string="$2";shift;;
*) ;;
esac
shift
done
local command=${1:-}

if [[ -n $command ]]; then
case $1 in
inbox) inbox;;
today) today;;
upcoming) upcoming;;
next) next;;
anytime) anytime;;
someday) someday;;
all) all;;
nextish) nextish;;
completed) completed;;
old) old;;
due) due;;
repeating) repeating;;
subtasks) subtasks;;
projects) projects;;
headings) headings;;
cancelled) cancelled;;
trashed) trashed;;
waiting) waiting;;
notes) notes;;
csv) csv|awk '{gsub("<[^>]*>", "")}1'|iconv -c -f UTF-8 -t WINDOWS-1252//TRANSLIT;;
stat) limitBy="999999" stat;;
search) search;;
feedback) open https://github.com/AlexanderWillner/things.sh/issues/;;
*) usage;;
esac
else
usage;
fi
}

[[ "${BASH_SOURCE[0]}" == "${0}" ]] && main "$@"
cleanup() {
: # nothing to clean up
# echo "$(date) $(hostname) $0: EXIT on line $2 (exit status $1)"
}

[[ "${BASH_SOURCE[0]}" == "${0}" ]] && trap 'cleanup $? $LINENO' EXIT && main "$@"

0 comments on commit ac630d0

Please sign in to comment.