aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-01-27 18:02:01 +0100
committerTeddy Wing2018-01-27 18:02:01 +0100
commit535aba7d41d82597471988fd847b496014c24344 (patch)
tree8330dfc6d8faabd255c712d7cb8ce01f470c013c
parent54c976418877d15971d4ea4544d308cdbff196ce (diff)
downloadharvester-535aba7d41d82597471988fd847b496014c24344.tar.bz2
harvester: Construct arguments to 'hcl'
Add a new function `hcl_log` that turns the project, time, date, and description arguments into the format the 'hcl' program expects.
-rwxr-xr-xharvester27
1 files changed, 26 insertions, 1 deletions
diff --git a/harvester b/harvester
index f585026..fdf51ee 100755
--- a/harvester
+++ b/harvester
@@ -14,6 +14,31 @@ Flags:
__EOF__
}
+function error_flag () {
+ local flag="$1"
+
+ echo "harvester: error: required flag $flag not provided, try --help"
+
+ exit 1
+}
+
+function hcl_log () {
+ local project="$1"
+ local time="$2"
+ local date="$3"
+ local description="$4"
+
+ if [ -z "$project" ]; then
+ error_flag '--project'
+ fi
+
+ if [ ! -z "$time" ]; then
+ time="+${time}"
+ fi
+
+ echo "${date} @${project} ${time} ${description}"
+}
+
function main () {
local project=''
local time=''
@@ -82,7 +107,7 @@ function main () {
esac
done
- echo "Project '$project'; Time '$time'; Date '$date'; Description '$description'"
+ hcl_log "$project" "$time" "$date" "$description"
}
main "$@"