aboutsummaryrefslogtreecommitdiff
path: root/gen_todo.sh
blob: 5cb94bb013464210e1b36c7e2ea42788c45b26b9 (plain)
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
#!/bin/bash
#
# Generate a TODO with a unique hash and priority level to allow tracking.
#
# Usage: ./gen_todo.sh 2 "Implement this."
#
# Output: TODO(P2-a07e5416): Implement this.

# Quit if any command produces an error.
set -e

# Check the positional arguments, assign defaults or prompt the user.
if [ $# -lt 2 ];
then
  read -p "Priority (ex: 0, 1, 2 or 3):"
  if [ -z $REPLY ]
  then
    PRIORITY="?"
  else
    PRIORITY=$REPLY
  fi

  read -p "Description (ex: 'Implement this.'):"
  TODO_TEXT=$REPLY
else
  PRIORITY=$1
  TODO_TEXT=$2
fi

# Build the TODO string.
TIME=`date +%s.%N`
SHASUM=`echo $TIME | shasum`
TODO_ID=${SHASUM:0:6}
TODO_STR="TODO(P$PRIORITY-$TODO_ID): $TODO_TEXT"
echo $TODO_STR