package bash_bleimport (shlex)// Snippet creates the bash-ble completion script.func ( *cobra.Command) string {returnSnippetSingle(.Name(), false)}// SnippetMulti creates a multi-completer bash-ble completion script.func ( []string, string, string) string { := bash.SnippetMulti(, , ) = regexp.MustCompile(`complete -o noquote -F [^\n]+`).ReplaceAllString(, "") := strings.Join(quoteAll(), " ")returnfmt.Sprintf(`%v_%[2]v_completer_ble() { if [[ ${BLE_ATTACHED-} ]]; then [[ :$comp_type: == *:auto:* ]] && return compopt -o ble/no-default bleopt complete_menu_style=desc local command="${COMP_WORDS[0]}" local compline="${COMP_LINE:0:${COMP_POINT}}" local IFS=$'\n' local c mapfile -t c < <(echo "$compline" | sed -e "s/ \$/ ''/" -e 's/"/\"/g' | xargs %[3]v "${command}" _carapace bash-ble) [[ "${c[*]}" == "" ]] && c=() # fix for mapfile creating a non-empty array from empty command output local cand for cand in "${c[@]}"; do [ ! -z "$cand" ] && ble/complete/cand/yield mandb "${cand%%$'\t'*}" "${cand##*$'\t'}" done else complete -F _%[2]v_completer %[4]v fi}complete -F _%[2]v_completer_ble %[4]v`, , , shlex.Quote(uid.Executable(), shlex.Bash), )}// SnippetSingle creates a single-command bash-ble completion script.// When explicitCommand is true, the command name is included in the invocation// (for multi-completer subcommands). When false, the executable is invoked// without an explicit command (standalone mode).func ( string, bool) string { := bash.SnippetSingle(, )if { = regexp.MustCompile(`complete -o noquote -F [^\n]+`).ReplaceAllString(, "") } else { = regexp.MustCompile(`complete -F [^\n]+`).ReplaceAllString(, "") } := fmt.Sprintf("%v _carapace bash-ble", shlex.Quote(uid.Executable(), shlex.Bash))if { = fmt.Sprintf("%v %v _carapace bash-ble", shlex.Quote(uid.Executable(), shlex.Bash), shlex.Quote(, shlex.Bash)) }returnfmt.Sprintf(`%v_%[2]v_completion_ble() { if [[ ${BLE_ATTACHED-} ]]; then [[ :$comp_type: == *:auto:* ]] && return compopt -o ble/no-default bleopt complete_menu_style=desc local compline="${COMP_LINE:0:${COMP_POINT}}" local IFS=$'\n' local c mapfile -t c < <(echo "$compline" | sed -e "s/ \$/ ''/" -e 's/"/\"/g' | xargs %[3]v) [[ "${c[*]}" == "" ]] && c=() # fix for mapfile creating a non-empty array from empty command output local cand for cand in "${c[@]}"; do [ ! -z "$cand" ] && ble/complete/cand/yield mandb "${cand%%$'\t'*}" "${cand##*$'\t'}" done else complete -F _%[2]v_completion %[2]v fi}complete -F _%[2]v_completion_ble %[2]v`, , , , shlex.Quote(, shlex.Bash))}func quoteAll( []string) []string { := make([]string, len())for , := range { [] = shlex.Quote(, shlex.Bash) }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.