aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-08-21 02:44:05 +0000
committerJulio Capote <jcapote@gmail.com>2022-08-21 02:44:05 +0000
commitbf922c47dedde37e3d97c4bf82f38e7d769fa267 (patch)
tree14c2c8a17250f93a0248bd9b887fa8562c26a345 /libexec
parent9e4f34a5989f6be48eaaebf17c8e42e61ebf3d76 (diff)
downloadrecit-bf922c47dedde37e3d97c4bf82f38e7d769fa267.tar.gz
move tomorrow/yesterday/today to entries
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/recit-add-entry1
-rwxr-xr-xlibexec/recit-entries40
-rwxr-xr-xlibexec/recit-today11
-rwxr-xr-xlibexec/recit-tomorrow9
-rwxr-xr-xlibexec/recit-yesterday9
5 files changed, 38 insertions, 32 deletions
diff --git a/libexec/recit-add-entry b/libexec/recit-add-entry
index 7cb5bb7..603128a 100755
--- a/libexec/recit-add-entry
+++ b/libexec/recit-add-entry
@@ -71,5 +71,6 @@ else
else
echo "$project not found, list of available projects:"
recsel -t Project -p Id ${recfile}
+ exit 1
fi
fi \ No newline at end of file
diff --git a/libexec/recit-entries b/libexec/recit-entries
index 343006d..dd495d8 100755
--- a/libexec/recit-entries
+++ b/libexec/recit-entries
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
-# Usage: recit entries [-p project-name]
+# Usage: recit entries [-p project-name] [-t time|today|yesterday|tomorrow]
+
+set -xe
# shellcheck source=/dev/null
source lib/loader
@@ -7,13 +9,17 @@ source lib/loader
recfile=$(load_recit)
project=""
+query_time=""
-while getopts "p:" options; do
+while getopts "p:t:" options; do
case "${options}" in
p)
project=${OPTARG}
;;
+ t)
+ query_time=${OPTARG}
+ ;;
:)
echo "Error: -${OPTARG} requires an argument."
exit 1
@@ -24,14 +30,36 @@ while getopts "p:" options; do
esac
done
-if [[ "$project" = "" ]]; then
- recsel -t Entry "${recfile}"
-else
+expression=""
+if ! [[ "$query_time" = "" ]]; then
+ if [[ "$query_time" = "today" ]]; then
+ fmt_date=$(date '+%Y-%m-%d')
+ elif [[ "$query_time" = "tomorrow" ]]; then
+ fmt_date=$(perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time + 86400)), qq(\n);")
+ elif [[ "$query_time" = "yesterday" ]]; then
+ fmt_date=$(perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time - 86400)), qq(\n);")
+ else
+ fmt_date=$query_time
+ fi
+ expression="((Time >> '$fmt_date 00:00:00' && Time << '$fmt_date 23:59:59') || Time == '$fmt_date')"
+fi
+
+if ! [[ "$project" = "" ]]; then
if recsel -t Project -p Id ${recfile} | grep "$project" > /dev/null; then
- recsel -e "ProjectRef = '$project'" -t Entry "${recfile}"
+ if [[ "$expression" = "" ]]; then
+ expression="ProjectRef = '$project'"
+ else
+ expression+=" && ProjectRef = '$project'"
+ fi
else
echo "$project not found, list of available projects:"
recsel -t Project -p Id ${recfile}
+ exit 1
fi
fi
+if [[ "$expression" = "" ]]; then
+ recsel -t Entry "${recfile}"
+else
+ recsel -t Entry -e "$expression" "${recfile}"
+fi
diff --git a/libexec/recit-today b/libexec/recit-today
index 96cbec4..a396e53 100755
--- a/libexec/recit-today
+++ b/libexec/recit-today
@@ -1,13 +1,4 @@
#!/usr/bin/env bash
# Usage: recit today
-set -e
-
-# shellcheck source=/dev/null
-source lib/loader
-
-recfile=$(load_recit)
-
-fmt_date=$(date '+%Y-%m-%d')
-
-recsel -e "(Time >> '$fmt_date 00:00:00' && Time << '$fmt_date 23:59:59') || Time == '$fmt_date'" -t Entry "${recfile}"
+recit-entries -t today
diff --git a/libexec/recit-tomorrow b/libexec/recit-tomorrow
index c5802d1..073912e 100755
--- a/libexec/recit-tomorrow
+++ b/libexec/recit-tomorrow
@@ -1,11 +1,4 @@
#!/usr/bin/env bash
# Usage: recit tomorrow
-# shellcheck source=/dev/null
-source lib/loader
-
-recfile=$(load_recit)
-
-fmt_date=$(perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time + 86400)), qq(\n);")
-
-recsel -e "(Time >> '$fmt_date 00:00:00' && Time << '$fmt_date 23:59:59') || Time == '$fmt_date'" -t Entry "${recfile}"
+recit-entries -t tomorrow \ No newline at end of file
diff --git a/libexec/recit-yesterday b/libexec/recit-yesterday
index ad6e804..48bcb96 100755
--- a/libexec/recit-yesterday
+++ b/libexec/recit-yesterday
@@ -1,11 +1,4 @@
#!/usr/bin/env bash
# Usage: recit yesterday
-# shellcheck source=/dev/null
-source lib/loader
-
-recfile=$(load_recit)
-
-fmt_date=$(perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time - 86400)), qq(\n);")
-
-recsel -e "(Time >> '$fmt_date 00:00:00' && Time << '$fmt_date 23:59:59') || Time == '$fmt_date'" -t Entry "${recfile}"
+recit-entries -t yesterday