diff options
| author | Teddy Wing | 2018-03-01 00:00:15 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-03-01 00:00:15 +0100 |
| commit | ee961907eabae3730753feb3b1a86a1bbb3ba12c (patch) | |
| tree | de9600c841df180ed1a0c6089a7c600dba3db639 | |
| parent | a66d6ed85250eaadaab7edcf976ab3f6d7a74fd7 (diff) | |
| parent | 9cff7d9059ba9834aebdb6806f65f408a705d934 (diff) | |
| download | harvester-ee961907eabae3730753feb3b1a86a1bbb3ba12c.tar.bz2 | |
Merge branch 'update-module'
| -rwxr-xr-x | harvester | 44 |
1 files changed, 41 insertions, 3 deletions
@@ -30,18 +30,25 @@ Flags: -d, --date=DATE Date when work was done (e.g. 2017-01-31). -m, --description=DESCRIPTION Description of work. --list-modules List project sprints with IDs. + --update-module Change the sprint of the given project. -v, --version Show application version. __EOF__ } -function error_flag () { - local flag="$1" +function exit_with_error () { + local message="$1" - echo "harvester: error: required flag $flag not provided, try --help" + echo "harvester: error: $message" 1>&2 exit 1 } +function error_flag () { + local flag="$1" + + exit_with_error "required flag $flag not provided, try --help" +} + function hcl_log () { local project="$1" local time="$2" @@ -68,6 +75,32 @@ function list_modules () { hcl tasks | grep "^${project_id}" } +function update_module () { + local project="$1" + + if [ -z "$project" ]; then + error_flag '--project' + fi + + if ! command -v pick > /dev/null; then + exit_with_error '--update-module requires `pick(1)` (https://github.com/calleerlandsson/pick)' + fi + + module_id=$(list_modules "$project" | + pick | + cut -d ' ' -f 1) + + if [ -z "$module_id" ]; then + exit_with_error 'bad module ID' + fi + + project_id="${module_id% *}" + task_id="${module_id#* }" + + hcl unalias "$project" + hcl alias "$project" "$project_id" "$task_id" +} + function main () { local project='' local time='7' @@ -129,6 +162,11 @@ function main () { return 0 ;; + --update-module) + update_module "$project" + + return + ;; --help) print_usage |
