diff options
| author | Teddy Wing | 2018-01-27 17:37:16 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-01-27 17:37:16 +0100 |
| commit | d300bbb967bea77e00ec0459bb2684d5fb87b3f8 (patch) | |
| tree | a3b257cc7d157ca715af8a682f52463aba53d9a8 | |
| download | harvester-d300bbb967bea77e00ec0459bb2684d5fb87b3f8.tar.bz2 | |
Add 'harvester'
Initial work on a Bash script that will become the Timetasker for
Harvest (using the 'hcl' command line utility).
Here we set up some basic option parsing thanks to this Stack Overflow
answer from 6EQUJ5:
https://stackoverflow.com/questions/22394407/handling-flags-for-a-shell-script-without-getopts/22395652#22395652
In it, a way to parse command-line options is described that works for
both short and long flags.
We'll be using these values to call out to 'hcl'.
| -rwxr-xr-x | harvester | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/harvester b/harvester new file mode 100755 index 0000000..aaa179c --- /dev/null +++ b/harvester @@ -0,0 +1,78 @@ +#!/bin/bash + +function get_value () { + local option="$1" +} + +function main () { + local project='' + local time='' + local date='' + local description='' + + while [ $# -gt 0 ]; do + # if [ "$1" = '-p' -o "$1" = '--project' ]; then + # fi + + case "$1" in + -p | --project) + project="$2" + + shift 2 + continue + ;; + --project=*) + project="${1##--project=}" + + shift + continue + ;; + -t | --time) + time="$2" + + shift 2 + continue + ;; + --time=*) + time="${1##--time=}" + + shift + continue + ;; + -d | --date) + date="$2" + + shift 2 + continue + ;; + --date=*) + date="${1##--date=}" + + shift + continue + ;; + -m | --description) + description="$2" + + shift 2 + continue + ;; + --description=*) + description="${1##--description=}" + + shift + continue + ;; + --list-modules) + shift + continue + ;; + --help) + ;; + esac + done + + echo "Project '$project'; Time '$time'; Date '$date'; Description '$description'" +} + +main "$@" |
