diff options
| author | Teddy Wing | 2018-01-27 18:02:01 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-01-27 18:02:01 +0100 |
| commit | 535aba7d41d82597471988fd847b496014c24344 (patch) | |
| tree | 8330dfc6d8faabd255c712d7cb8ce01f470c013c | |
| parent | 54c976418877d15971d4ea4544d308cdbff196ce (diff) | |
| download | harvester-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-x | harvester | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -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 "$@" |
