From 76b80294047d05360e8069f5c397c9850674cd54 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sun, 21 Aug 2022 11:52:45 -0400 Subject: add getopts to add-project --- libexec/recit-add-project | 22 ++++++++++++++++++++-- libexec/recit-projects | 5 ++++- share/recit/recit.example.rec | 6 ++++-- share/recit/templates/projects.templ | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/libexec/recit-add-project b/libexec/recit-add-project index aa60b9e..2f30607 100755 --- a/libexec/recit-add-project +++ b/libexec/recit-add-project @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Usage: recit add-project "notes" +# Usage: recit add-project -n my-project # Summary: Add Project @@ -8,4 +8,22 @@ source lib/loader recfile=$(load_recit) -recins --verbose -f Id -v "$1" -t Project "${recfile}" \ No newline at end of file +name="" +while getopts "n:" options; do + case "${options}" in + n) + name=${OPTARG} + ;; + :) + echo "Error: -${OPTARG} requires an argument." + exit 1 + ;; + *) + exit 1 + ;; + esac +done + +fmt_date=$(date '+%Y-%m-%d %r') + +recins --verbose -f Id -v "$name" -f Status -v "open" -f Created -v "$fmt_date" -t Project "${recfile}" \ No newline at end of file diff --git a/libexec/recit-projects b/libexec/recit-projects index 4217397..8f4ba18 100755 --- a/libexec/recit-projects +++ b/libexec/recit-projects @@ -2,4 +2,7 @@ # Usage: recit projects # Summary: List all Projects -recit-recsel-projects +recit-recsel-projects "Status = 'open'" +echo +echo "-----------" +recit-recsel-projects "Status = 'closed'" diff --git a/share/recit/recit.example.rec b/share/recit/recit.example.rec index ec394d6..27e9f4d 100644 --- a/share/recit/recit.example.rec +++ b/share/recit/recit.example.rec @@ -2,8 +2,10 @@ # Version: 0.0.2 %rec: Project %key: Id -%mandatory: Name Status -%allowed: Notes +%mandatory: Status Created +%allowed: Notes Created +%type: Created date +%auto: Created %rec: Entry %key: Id diff --git a/share/recit/templates/projects.templ b/share/recit/templates/projects.templ index cfe77ba..35be230 100644 --- a/share/recit/templates/projects.templ +++ b/share/recit/templates/projects.templ @@ -1,3 +1,3 @@ -\033[1;33m{{Id}}\033[0m ({{Status}}) +{{Created}} \033[1;33m{{Id}}\033[0m ({{Status}}) {{Notes}} -- cgit v1.2.3