Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: bash completion generation via a command #4551

Closed
renich opened this issue Jan 5, 2018 · 1 comment · Fixed by #8043
Closed

Feature Request: bash completion generation via a command #4551

renich opened this issue Jan 5, 2018 · 1 comment · Fixed by #8043
Labels
help wanted Seeking public contribution on this issue kind/feature A new feature

Comments

@renich
Copy link

renich commented Jan 5, 2018

Version information:

$ ipfs version --all
go-ipfs version: 0.4.13-
Repo version: 6
System version: amd64/linux
Golang version: go1.9.2

Type:

Enhancement

Severity:

N/A

Description:

Currently, ipfs provides bash completion through: https://github.com/ipfs/go-ipfs/blob/master/docs/command-completion.md

IMHO, it is much easier if you could just generate the bash completion script with, say: ipfs completion bash > /etc/bash_completion.d/ipfs. This feature is implemented by k8s, for example:

$ kubectl completion bash 

# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# bash completion for kubectl                              -*- shell-script -*-

__debug()
{
    if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
        echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
    fi
}

# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
# _init_completion. This is a very minimal version of that function.
__my_init_completion()
{
    COMPREPLY=()
    _get_comp_words_by_ref "$@" cur prev words cword
}

__index_of_word()
{
    local w word=$1
    shift
    index=0
    for w in "$@"; do
        [[ $w = "$word" ]] && return
        index=$((index+1))
    done
    index=-1
}
...

Which means that this is generated programmatically and, probably, using introspection. In any case, this would be easier to maintain, IMHO.

Not clear enough (up there, you have Feature as an option). Sorry if I made a feature request where it wasn't allowed.

@Stebalien
Copy link
Member

The trickiest part will be completing paths. It would be awesome if we could do that reliably but that will take some modifications to the cmds library.

However, simply completing commands and flags is totally doable.

@Stebalien Stebalien added kind/feature A new feature help wanted Seeking public contribution on this issue labels Apr 5, 2020
Stebalien added a commit that referenced this issue Apr 1, 2021
These are missing some of the features of the current hand-rolled
completions, but:

1. Are less buggy.
2. Cover _all_ commands.
3. Don't need to be manually maintained (which we never do anyways).

fixes #4551
fixes #8033
Stebalien added a commit that referenced this issue Apr 1, 2021
These are missing some of the features of the current hand-rolled
completions, but:

1. Are less buggy.
2. Cover _all_ commands.
3. Don't need to be manually maintained (which we never do anyways).

fixes #4551
fixes #8033
Stebalien added a commit that referenced this issue Apr 1, 2021
These are missing some of the features of the current hand-rolled
completions, but:

1. Are less buggy.
2. Cover _all_ commands.
3. Don't need to be manually maintained (which we never do anyways).

fixes #4551
fixes #8033
Stebalien added a commit that referenced this issue Jul 1, 2021
These are missing some of the features of the current hand-rolled
completions, but:

1. Are less buggy.
2. Cover _all_ commands.
3. Don't need to be manually maintained (which we never do anyways).

fixes #4551
fixes #8033
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/feature A new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants