Last active
January 21, 2019 20:08
-
-
Save EdwardReed/d6f72856271109237a3c21bca5ef0fb7 to your computer and use it in GitHub Desktop.
revtracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run `tracktime [day of week] [project] [hours] [category] [notes]` | |
# | |
# Examples: | |
# tracktime mon cont 1 impl "drafted #363" | |
# tracktime monday content "1.0" implement | |
# tracktime fri meet 1 | |
# | |
# If you forget what order the arguments go in, run `tracktime help` | |
match(){ | |
echo "$2" | grep -q "$1" | |
} | |
fuzzyfind(){ | |
# PROJECTS | |
if match $1 content; then echo "Content" | |
elif match $1 tss; then echo "TSS Phase 1" | |
elif match $1 meetings; then echo "Company Meetings" | |
elif match $1 sick; then echo "PTO - Sick" | |
# CATEGORIES | |
elif match $1 design; then echo "Design" | |
elif match $1 devops; then echo "DevOps" | |
elif match $1 implementation; then echo "Implementation" | |
elif match $1 internaltime; then echo "Internal Time" | |
elif match $1 nonbillable; then echo "Non-Billable" | |
elif match $1 projectplanning; then echo "Project Planning" | |
elif match $1 qa; then echo "QA" | |
elif match $1 support; then echo "Support" | |
elif match $1 travel; then echo "Travel" | |
else | |
echo "No match found!" | |
return 1 | |
fi | |
} | |
tracktime(){ | |
# CONSTANTS | |
NAME="Edward Reed II" | |
DEFAULT_CATEGORY="Implementation" | |
BASEURL="https://airtable.com/shrV4tXD46VGk42JM?prefill_Name=$NAME" | |
URL=$BASEURL | |
# INPUTS | |
DAY=$1 | |
PROJECT=$2 | |
TIME=$3 | |
CATEGORY=$4 | |
NOTES=$5 | |
if [[ "$1" == "help" ]]; then | |
echo "usage: tracktime [day] [project] [hours] [category] [notes]" | |
return 1 | |
fi | |
if [[ "$DAY" ]]; then URL="$BASEURL&prefill_Date=$(date -v $DAY +%m/%d/%Y)" fi | |
if [[ "$PROJECT" ]]; then URL="$URL&prefill_Project=$(fuzzyfind $PROJECT)" fi | |
if [[ "$TIME" ]]; then URL="$URL&prefill_Hours=$TIME" fi | |
if [[ "$NOTES" ]]; then URL="$URL&prefill_Notes=$NOTES" fi | |
if [[ "$CATEGORY" ]]; then | |
URL="$URL&prefill_Category=$(fuzzyfind $CATEGORY)" | |
else | |
URL="$URL&prefill_Category=$DEFAULT_CATEGORY" | |
fi | |
echo $URL | |
open "$URL" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment