forked from todotxt/todo.txt-cli
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpaper
executable file
·110 lines (100 loc) · 1.52 KB
/
paper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# 2010 Matthew Bauer
# License: GPL, http://www.gnu.org/copyleft/gpl.html
usage(){
echo "$(basename $0) [todo_file]"
echo " Print your todo file."
echo " Defaults to todo.txt"
}
get_tasks_raw(){
## If the file starts with a "/" use absolute path. Otherwise,
## try to find it in either $TODO_DIR or using a relative path
if [ "${1:0:1}" == / ]
then
## Absolute path
src="$1"
elif [ -f "$TODO_DIR/$1" ]
then
## Path relative to todo.sh directory
src="$TODO_DIR/$1"
elif [ -f "$1" ]
then
## Path relative to current working directory
src="$1"
else
echo "TODO: File $1 does not exist."
return 1
fi
cat "$src"
}
get_tasks_markdown(){
echo 'todo.txt-paper'
echo '===================='
echo
get_tasks_raw "$1" | while read line
do
echo "$line"
done
}
print_tasks(){
get_tasks_raw "$1" | lpr
}
if [ -z "$TODO_DIR" ]
then
source ~/.todo/config
fi
if [ -z "$@" ]
then
print_tasks "$TODO_FILE"
exit
fi
ran=0
raw=0
options=""
while true; do
case "$1" in
usage|--help|-h|help)
usage
break
;;
-r|--raw)
raw=1
;;
-d|-p|--destination|--printer)
shift
if [ -z "$options" ]
then
options="-d $1"
else
options="$options -d $1"
fi
;;
-o|--options|-l|--lp|--lp-options)
shift
options="$1"
;;
-N|--no-raw|-R)
raw=0
;;
-n|--no-run)
ran=1
;;
'')
if [ $ran == 0 ]
then
print_tasks "$TODO_FILE"
fi
break
;;
*)
if [ $raw == 0 ]
then
print_tasks "$1"
else
get_tasks "$1"
fi
ran=1
;;
esac
shift
done