aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlibexec/recit-add-entry51
-rwxr-xr-xlibexec/recit-projects (renamed from libexec/recit-open-projects)0
2 files changed, 40 insertions, 11 deletions
diff --git a/libexec/recit-add-entry b/libexec/recit-add-entry
index ae0be2f..7cb5bb7 100755
--- a/libexec/recit-add-entry
+++ b/libexec/recit-add-entry
@@ -8,21 +8,42 @@ source lib/loader
recfile=$(load_recit)
-uuid=$(uuidgen)
-
notes=""
query_time=""
+project=""
+
+while getopts "p:m:t:" options; do
+
+ case "${options}" in
+ p)
+ project=${OPTARG}
+ ;;
+ m)
+ notes=${OPTARG}
+ ;;
+ t)
+ query_time=${OPTARG}
+ ;;
+ :)
+ echo "Error: -${OPTARG} requires an argument."
+ exit 1
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+done
+
+uuid=$(uuidgen)
-if [[ -z "$1" ]]; then
+if [[ "$query_time" = "" ]]; then
query_time="now"
-else
- query_time="$1"
fi
-if [[ -z "$2" ]]; then
+if [[ "$notes" = "" ]]; then
if [[ -z ${EDITOR+x} ]]; then
- echo "$EDITOR is not defined please pass a message"
+ echo "$EDITOR is not defined please pass a message with -m"
exit 1
fi
@@ -30,8 +51,6 @@ if [[ -z "$2" ]]; then
command $EDITOR "$tmpfile"
notes=$(cat "$tmpfile")
rm "$tmpfile"
-else
- notes=$2
fi
if [[ "$query_time" == "now" || "$query_time" == "today" ]]; then
@@ -42,5 +61,15 @@ else
fmt_date=$query_time
fi
-recins --verbose -f Id -v "$uuid" -f Time -v "$fmt_date" -f Notes -v "$notes" -t Entry "${recfile}"
-echo "$uuid" \ No newline at end of file
+if [[ "$project" = "" ]]; then
+ recins --verbose -f Id -v "$uuid" -f Time -v "$fmt_date" -f Notes -v "$notes" -t Entry "${recfile}"
+ echo "$uuid"
+else
+ if recsel -t Project -p Id ${recfile} | grep "$project" > /dev/null; then
+ recins --verbose -f Id -v "$uuid" -f Time -v "$fmt_date" -f Notes -v "$notes" -f ProjectRef -v "$project" -t Entry "${recfile}"
+ echo "$uuid"
+ else
+ echo "$project not found, list of available projects:"
+ recsel -t Project -p Id ${recfile}
+ fi
+fi \ No newline at end of file
diff --git a/libexec/recit-open-projects b/libexec/recit-projects
index efb323f..efb323f 100755
--- a/libexec/recit-open-projects
+++ b/libexec/recit-projects