restructured project

This commit is contained in:
Tristan Ancelet
2023-06-14 14:15:13 -05:00
parent 9616b56f53
commit a27e7f561e
13 changed files with 185 additions and 44 deletions

View File

@@ -0,0 +1,8 @@
#!/usr/bin/bash
function get_journals () {
local JOURNAL_REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}.wiki'
[[ "$1" ]] && declare -n hashmap="$1"
hashmap=( $( ls $JOURNAL_DIR -1 | grep -Eo $JOURNAL_REGEX | sort -n ) )
}

26
scripts/utils/tasks.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/bash
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
function get_tasks () {
set -x
local -a journals
get_journals journals
local TASK_REGEX='====[[:space:]]+.+[[:space:]]+===='
declare -n TODO="$1"
declare -n DONE="$2"
for journal in "${journals[@]}"; do
if grep -Eo $TASK_REGEX $journal >/dev/null 2>&1; then
while read line; do
if [[ "$line" == *'(DUE: DONE)'* ]]; then
DONE["$journal"]="$( echo -e "${DONE["$journal"]}\n$line" )"
else
TODO["$journal"]="$( echo -e "${TODO["$journal"]}\n$line" )"
fi
done <<< "$( grep -Eo $TASK_REGEX $journal | tr '=' ' ')"
fi
done
}

16
scripts/utils/topics.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/bash
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
function get_tasks () {
local -a journals
get_journals journals
local TOPIC_REGEX='^=== .+ ==='
declare -n TOPICS="$1"
for journal in "${journals[@]}"; do
if grep -E "$TOPIC_REGEX" $journal >/dev/null 2>&1; then
TOPICS["$journal"]="$( grep -Eo "$TOPIC_REGEX" $journal | tr '=' ' ' )"
fi
done
}