commit e44e3dfde6f4bb7f7c884fc7b5f072b83e864a7c
parent ef19656b1c9deb54c9e6e048a3937c2b52c0a69e
Author: Sean Enck <sean@ttypty.com>
Date: Mon, 27 Mar 2023 19:21:34 -0400
cleanup completions file spacing
Diffstat:
1 file changed, 70 insertions(+), 68 deletions(-)
diff --git a/internal/cli/completions.bash b/internal/cli/completions.bash
@@ -1,78 +1,80 @@
# {{ $.Executable }} completion
_{{ $.Executable }}() {
- local cur opts
- cur=${COMP_WORDS[COMP_CWORD]}
- if [ "$COMP_CWORD" -eq 1 ]; then
- {{range $idx, $value := $.Options }}
- opts="${opts}{{ $value }} "{{end}}
- # shellcheck disable=SC2207
- COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
+ local cur opts
+ cur=${COMP_WORDS[COMP_CWORD]}
+ if [ "$COMP_CWORD" -eq 1 ]; then
+{{- range $idx, $value := $.Options }}
+ opts="${opts}{{ $value }} "
+{{- end}}
+ # shellcheck disable=SC2207
+ COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
+ else
+ if [ "$COMP_CWORD" -eq 2 ]; then
+ case ${COMP_WORDS[1]} in
+{{- if not $.ReadOnly }}
+ "{{ $.InsertCommand }}")
+{{- range $key, $value := .InsertSubCommands }}
+ opts="$opts {{ $value }}"
+{{- end}}
+ opts="$opts $({{ $.DoList }})"
+ ;;
+ "{{ $.HelpCommand }}")
+ opts="{{ $.HelpAdvancedCommand }}"
+ ;;
+ "{{ $.MoveCommand }}")
+ opts=$({{ $.DoList }})
+ ;;
+{{- end}}
+{{- if $.CanTOTP }}
+ "{{ $.TOTPCommand }}")
+ opts="{{ $.TOTPListCommand }} "
+{{- range $key, $value := .TOTPSubCommands }}
+ opts="$opts {{ $value }}"
+{{- end}}
+ opts="$opts "$({{ $.DoTOTPList }})
+ ;;
+{{- end}}
+ "{{ $.ShowCommand }}" | "{{ $.StatsCommand }}" {{ if not $.ReadOnly }}| "{{ $.RemoveCommand }}" {{end}} {{ if $.CanClip }} | "{{ $.ClipCommand }}" {{end}})
+ opts=$({{ $.DoList }})
+ ;;
+ esac
else
- if [ "$COMP_CWORD" -eq 2 ]; then
- case ${COMP_WORDS[1]} in
-{{ if not $.ReadOnly }}
- "{{ $.InsertCommand }}")
-{{ range $key, $value := .InsertSubCommands }}
- opts="$opts {{ $value }}"
-{{end}}
- opts="$opts $({{ $.DoList }})"
- ;;
- "{{ $.HelpCommand }}")
- opts="{{ $.HelpAdvancedCommand }}"
- ;;
- "{{ $.MoveCommand }}")
- opts=$({{ $.DoList }})
- ;;
-{{end}}
-{{ if $.CanTOTP }}
- "{{ $.TOTPCommand }}")
- opts="{{ $.TOTPListCommand }} "
-{{ range $key, $value := .TOTPSubCommands }}
- opts="$opts {{ $value }}"
-{{end}}
- opts="$opts "$({{ $.DoTOTPList }})
- ;;
-{{end}}
- "{{ $.ShowCommand }}" | "{{ $.StatsCommand }}" {{ if not $.ReadOnly }}| "{{ $.RemoveCommand }}" {{end}} {{ if $.CanClip }} | "{{ $.ClipCommand }}" {{end}})
- opts=$({{ $.DoList }})
- ;;
+ if [ "$COMP_CWORD" -eq 3 ]; then
+ case "${COMP_WORDS[1]}" in
+{{- if not $.ReadOnly }}
+ "{{ $.InsertCommand }}")
+ case "${COMP_WORDS[2]}" in
+{{- range $key, $value := .InsertSubCommands }}
+ "{{ $value }}")
+ opts=$({{ $.DoList }})
+ ;;
+{{- end }}
esac
- fi
- if [ "$COMP_CWORD" -eq 3 ]; then
- case "${COMP_WORDS[1]}" in
-{{ if not $.ReadOnly }}
- "{{ $.InsertCommand }}")
- case "${COMP_WORDS[2]}" in
-{{ range $key, $value := .InsertSubCommands }}
- "{{ $value }}")
- opts=$({{ $.DoList }})
- ;;
-{{end}}
- esac
- ;;
- "{{ $.MoveCommand }}")
- opts=$({{ $.DoList }})
- ;;
-{{end}}
-{{ if $.CanTOTP }}
- "{{ $.TOTPCommand }}")
- case "${COMP_WORDS[2]}" in
-{{ range $key, $value := .TOTPSubCommands }}
- "{{ $value }}")
- opts=$({{ $.DoTOTPList }})
- ;;
-{{end}}
- esac
- ;;
-{{end}}
+ ;;
+ "{{ $.MoveCommand }}")
+ opts=$({{ $.DoList }})
+ ;;
+{{- end }}
+{{- if $.CanTOTP }}
+ "{{ $.TOTPCommand }}")
+ case "${COMP_WORDS[2]}" in
+{{- range $key, $value := .TOTPSubCommands }}
+ "{{ $value }}")
+ opts=$({{ $.DoTOTPList }})
+ ;;
+{{- end}}
esac
- fi
- if [ -n "$opts" ]; then
- # shellcheck disable=SC2207
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
- fi
+ ;;
+{{- end}}
+ esac
+ fi
fi
+ if [ -n "$opts" ]; then
+ # shellcheck disable=SC2207
+ COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ fi
+ fi
}
complete -F _{{ $.Executable }} -o bashdefault -o default {{ $.Executable }}