Browse Source

adding the beginnings of assets

master
Ben Savage 4 years ago
parent
commit
5c535746f2
  1. 51
      cl

51
cl

@ -35,6 +35,10 @@ $0 - Captain's log
Directories created under $BASEDIR are treated as profiles (if they exist). The default profile is assumed to be 'default'.
Specify -p <profile> as the first argument to $0 to operate on a different one
Run with "asset" to spin up a new empty file with an asset tag. This is currently assumed to be plain text that complements the log, but makes little sense to included.
At some point this will be expanded to handle other files
Run with "asset <ID>" to open said asset.
Run with "review" ($0 review), and you will get a rundown of complete and incomplete tasks for the week.
Optionally, supply with date-compatible strings as "$0 review <start> [end] to use a range, end defaults to yesterday
@ -58,7 +62,6 @@ EOF
}
function review() {
shift
DATE_START=${1:-"-7 days"}
DATE_END=${2:-"yesterday"}
@ -100,7 +103,6 @@ function review() {
}
function schedule() {
shift
if [ "$1" == "edit" ]; then
if [ -f "$CLDIR/schedule"* ];then
@ -217,6 +219,44 @@ function captains_log() {
fi
fi
}
function asset() {
ASSET_DIR="$CLDIR/assets/"
ADB="$ASSET_DIR/db"
if [ ${1:-0} != 0 ]; then
if [[ $1 =~ (\[?ASSET:)?[a-zA-Z0-9]+\]? ]]; then
ID="$(echo "$1"|grep -oE '[a-zA-Z0-9]{8}')"
vi "$ASSET_DIR/$ID"
fi
else
if ! [ -d "$ASSET_DIR" ]; then
mkdir "$ASSET_DIR"
touch $ADB
fi
# Generate a random ID that doesn't already exist
while grep -qi "$ID" "${ADB}"; do
ID="$(openssl rand -hex 4)"
# Alternatively
#hexdump -n 4 -e '/4 "%08X" 1 "\n"' /dev/urandom
done
echo "$ID:type text" >> "$ADB"
echo "[ASSET:$ID]" > "$ASSET_DIR/$ID"
vi "$ASSET_DIR/$ID"
fi
}
BASEDIR="$HOME/.captains_log"
# Check if there are any profiles, otherwise just use the basedir
@ -225,13 +265,16 @@ if [ "$(find $BASEDIR -type d|wc -l)" -gt 1 ]; then
else
CLDIR="$BASEDIR"
fi
while [ $1 ]; do
case $1 in
-p|--profile) CLDIR="$BASEDIR/$2"; shift 2;;
--no-git) GIT=0;shift;;
--debug) DEBUG=1; shift;;
review) review "$@"; exit;;
schedule) schedule "$@";exit;;
review) shift; review "$@"; exit;;
schedule) shift; schedule "$@";exit;;
asset) shift; asset "$@"; exit;;
help|--help|-h) help; exit;;
*) break;;
esac

Loading…
Cancel
Save