Skip to content
Snippets Groups Projects
Commit 28fe956a authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- added first draft for bash completion, needs more work!

parent 30ea5e8a
No related branches found
No related tags found
No related merge requests found
SELF=./validate_workflow.sh
_validate_workflow_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(cat $SELF | grep "^#hh\s-., --[a-z]" | sed -e "s/^#hh.*\(-.\), \(--[a-z-]*\).*/\1 \2/g")
2>&1 echo "OPTS:$opts"
case "$prev" in
--pipe)
prev=$(echo $prev | sed -e "s/--\(daemon\|watch-folder\|result_folder\|valid_folder\|invalid_folder\)//g")
return 0
;;
--mode)
COMPREPLY=( $(compgen -W "auto mediathek fotothek save kitodo lfulg" -- ${cur}) )
return 0
;;
--files-mode)
COMPREPLY=( $(compgen -W "nothing sort delete" -- ${cur}) )
return 0
;;
-reset_failed_preingest|--reset_failed_preingest)
_pushd /mnt/import
_filedir -d
_popd
return
;;
esac
# debug
2>&1 echo "PREVS:$prevs"
}
complete -F _validate_workflow_completion validate_workflow.sh
...@@ -54,7 +54,9 @@ ...@@ -54,7 +54,9 @@
#hh -p, --pipe #hh -p, --pipe
#hh validates a single filestream from STDIN, writes result to STDOUT #hh validates a single filestream from STDIN, writes result to STDOUT
#hh no daemon, no folder nor filemode params needed #hh no daemon, no folder nor filemode params needed
#hh #hh -G, --gen-bash-complete
#hh prints a script for bash autocompletion, should be copied
#hh to /etc/bash_completion.d/validate_workflow
#hh #hh
# expected programs: # expected programs:
...@@ -171,6 +173,14 @@ get_cli_args() { ...@@ -171,6 +173,14 @@ get_cli_args() {
comment_help comment_help
exit 0 exit 0
;; ;;
-G | --gen_bash_complete)
cat <<COMPLETE
complete -F _validate_workflow_completion $(basename "${0}")
COMPLETE
exit 0
;;
-D | --debug) -D | --debug)
WITH_DEBUG=1 WITH_DEBUG=1
shift shift
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment