Skip to content

Custom fish completions do not work #376

@floam

Description

@floam

I was looking over some issues, and for fun cloned https://gitlab.com/frizlab-demo-projects/swift-argument-parser-example-for-pr-320 which was a test case for a problem that affected bash and not zsh for issue #320. Was just interested in verifying it had the correct behavior for fish. This is the first project using argument-parser I've compiled. It seems custom completions are not generated for fish at all. I expect there to be something executing ---completion … in the output?

$ example --generate-completion-script=fish
function __fish_example_using_command
    set cmd (commandline -opc)
    if [ (count $cmd) -eq (count $argv) ]
        for i in (seq (count $argv))
            if [ $cmd[$i] != $argv[$i] ]
                return 1
            end
        end
        return 0
    end
    return 1
end
complete -c example -n '__fish_example_using_command example' -f -r -l option1
$ example --generate-completion-script=zsh
#compdef example
local context state state_descr line
_example_commandname=$words[1]
typeset -A opt_args

_example() {
    integer ret=1
    local -a args
    args+=(
        '--option1:option1:'
        ':arg:{_custom_completion $_example_commandname ---completion  -- arg $words}'
        '(-h --help)'{-h,--help}'[Print help information.]'
    )
    _arguments -w -s -S $args[@] && ret=0

    return ret
}


_custom_completion() {
    local completions=("${(@f)$($*)}")
    _describe '' completions
}

_example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions