diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-13 07:30:30 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-13 07:30:30 +0100 |
commit | 0cecee141d8b1a00d89967a1c9afa90839b23b98 (patch) | |
tree | 37f082c2171d96cb849a52825b714a3cddc80585 | |
parent | b54e8f3cb5ca55ba630f45cb8a6d11789b64585e (diff) |
Adds jobbly logger sqlite wrapper script
-rwxr-xr-x | jobblylogger.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/jobblylogger.sh b/jobblylogger.sh new file mode 100755 index 0000000..b3e2b5c --- /dev/null +++ b/jobblylogger.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Check if both date and comment are provided +if [ $# -lt 2 ]; then + echo "Usage: $0 <date> <comment>" + exit 1 +fi + +# Extract date and comment from command line arguments +date="$1" +comment="$2" + +# Format the date string to match SQLite's format (YYYY-MM-DD HH:MM:SS) +formatted_date=$(date -d "$date" +"%Y-%m-%d %H:%M:%S") + +# SQLite command to insert the record +sqlite3 ~/Documents/Notes/jobblylogger.db "INSERT INTO jobbies (date, comments) VALUES ('$formatted_date', '$comment');" + +# Check if the insertion was successful +if [ $? -eq 0 ]; then + echo "Record inserted successfully." +else + echo "Failed to insert record." +fi + |