[bitbake-devel] Add files supporting bash completion for bitbake tools

Alexander Kanavin alex.kanavin at gmail.com
Mon Sep 3 09:25:01 UTC 2018


Hello Lukasz,

nobody will find your contributions in bitbake/contrib, and so they
will be unused and will bitrot. The proper place is the upstream
bash-completion project, which will get picked up by all Linux
distributions.

Alex

2018-09-02 12:27 GMT+02:00 Łukasz Gardoń <lukaszgardon555 at gmail.com>:
> Hi Alex,
>
> With information comes file from bitbake repository -
> bitbake/contrib/README: "This directory is for additional contributed files
> which may be useful.”.
> I think that this is proper place for such files.
>
> Wiadomość napisana przez Alexander Kanavin <alex.kanavin at gmail.com> w dniu
> 01.09.2018, o godz. 21:33:
>
> The right upstream destination for this is almost certainly
> https://github.com/scop/bash-completion
>
> Alex
>
> 2018-09-01 15:36 GMT+02:00 Łukasz Gardoń <lukaszgardon555 at gmail.com>:
>
> Repository with more details:
> https://github.com/lukaszgard/bitbake-completion
>
> Signed-off-by: Łukasz Gardoń <lukaszgardon555 at gmail.com>
> ---
> contrib/completion/bash/bitbake_completion    | 108 ++++++++++
> .../bash/bitbake_diffsigs_completion          |  86 ++++++++
> .../bash/bitbake_dumpsig_completion           |  89 +++++++++
> .../completion/bash/bitbake_layers_completion | 188 ++++++++++++++++++
> .../completion/bash/bitbake_prserv_completion |  76 +++++++
> .../bash/bitbake_selftest_completion          |  34 ++++
> 6 files changed, 581 insertions(+)
> create mode 100644 contrib/completion/bash/bitbake_completion
> create mode 100644 contrib/completion/bash/bitbake_diffsigs_completion
> create mode 100644 contrib/completion/bash/bitbake_dumpsig_completion
> create mode 100644 contrib/completion/bash/bitbake_layers_completion
> create mode 100644 contrib/completion/bash/bitbake_prserv_completion
> create mode 100644 contrib/completion/bash/bitbake_selftest_completion
>
> diff --git a/contrib/completion/bash/bitbake_completion
> b/contrib/completion/bash/bitbake_completion
> new file mode 100644
> index 00000000..23cadf6e
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_completion
> @@ -0,0 +1,108 @@
> +#!bash
> +# Bash completion support for bitbake 1.39.1 release.
> +#
> +# Copyright (C) 2014 Sergio Prado <sergio.prado at e-labworks.com>
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake()
> +{
> +    local cur prev opts_short opts_long tasks recipes ui
> +    local bb_layers_conf bb_layers_md5 bb_recipes
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-h -b -k -f -c -C -r -R -v -D -q -n -S -p -s -e -g -I \
> +                -l -P -u -B -T -m -w"
> +
> +    opts_long="--version --help --buildfile= --continue --force --cmd= \
> +               --clear-stamp= --read= --postread= --verbose --debug --quiet
> \
> +               --dry-run --dump-signatures= --parse-only --show-versions \
> +               --environment --graphviz --ignore-deps= --log-domains=
> --profile \
> +               --ui= --token= --revisions-changed --server-only --bind= \
> +               --idle-timeout= --no-setscene --setscene-only
> --remote-server= \
> +               --kill-server --observe-only --status-only --write-log=
> --runall= \
> +               --runonly="
> +
> +    tasks="build compile compile_ptest_base configure configure_ptest_base
> deploy \
> +           distrodata fetch image image_complete install install_ptest_base
> package \
> +           package_qa package_write_deb package_write_ipk package_write_rpm
> package_write_tar \
> +           packagedata patch populate_lic populate_sdk populate_sysroot
> prepare_recipe_sysroot \
> +           rm_work rm_work_all unpack checkpkg checkuri clean cleanall
> cleansstate devpyshell \
> +           devshell listtasks package_index bootimg bundle_initramfs rootfs
> testimage \
> +           testimage_auto compile_kernelmodules diffconfig kernel_checkout
> kernel_configcheck \
> +           kernel_configme kernel_menuconfig kernel_metadata menuconfig
> savedefconfig shared_workdir \
> +           sizecheck strip validate_branches spdx"
> +
> +    ui="knotty ncurses taskexp"
> +
> +    if [[ "$prev" == "=" ]]; then
> +        prev="${COMP_WORDS[COMP_CWORD - 2]}"
> +    elif [[ "$cur" == "=" ]]; then
> +        cur=""
> +    fi
> +
> +    conf_files=$(find . -maxdepth 1 -name "*.conf" -type f -printf '%P\n')
> +
> +    case "$prev" in
> +
> "-c"|"--cmd"|"-C"|"--clear-stamp"|"--ignore-deps"|"--runall"|"--runonly")
> +            COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-r"|"--read"|"-R"|"--postread")
> +            COMPREPLY=( $(compgen -W "${conf_files}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-u"|"--ui")
> +            COMPREPLY=( $(compgen -W "${ui}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    case "$cur" in
> +        "--"*)
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == "--"*"=" ]] ;
> then
> +                compopt -o nospace
> +            fi
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    bb_layers_conf="conf/bblayers.conf"
> +    bb_layers_md5=".bb_layers_conf.md5"
> +    bb_recipes=".bb_recipes"
> +
> +    _parse_recipes () {
> +        bitbake -s | sed -e '0,/^=.*/d' -e '/^\s*$/d' -e '/^Summary:/d' |
> awk '{print $1}' > $bb_recipes
> +    }
> +
> +    if [ ! -e $bb_layers_conf ]; then
> +        return 0
> +    fi
> +
> +    if [ "$prev" = "bitbake" -a "$cur" = "" ]; then
> +        _parse_recipes
> +    fi
> +
> +    md5sum --quiet --status -c $bb_layers_md5 2>/dev/null
> +    if [ $? != 0 -o ! -e $bb_recipes ]; then
> +         md5sum $bb_layers_conf > $bb_layers_md5
> +         _parse_recipes
> +    fi
> +
> +    recipes=$(cat $bb_recipes)
> +
> +    COMPREPLY=( $(compgen -W "${recipes}" -- ${cur}) )
> +    return 0
> +}
> +complete -F _bitbake bitbake
> \ No newline at end of file
> diff --git a/contrib/completion/bash/bitbake_diffsigs_completion
> b/contrib/completion/bash/bitbake_diffsigs_completion
> new file mode 100644
> index 00000000..cbf2c5f1
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_diffsigs_completion
> @@ -0,0 +1,86 @@
> +#!bash
> +# Bash completion support for bitbake-diffsigs tool,
> +# compatible with Bitbake 1.39.1.
> +#
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake_diffsigs()
> +{
> +    local cur prev opts_short opts_long tasks colors
> +    local bb_layers_conf bb_layers_md5 bb_recipes
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-h -d -t -s"
> +
> +    opts_long="--help --debug --color --task --signature"
> +
> +    tasks="build compile compile_ptest_base configure configure_ptest_base
> deploy \
> +           distrodata fetch image image_complete install install_ptest_base
> package \
> +           package_qa package_write_deb package_write_ipk package_write_rpm
> package_write_tar \
> +           packagedata patch populate_lic populate_sdk populate_sysroot
> prepare_recipe_sysroot \
> +           rm_work rm_work_all unpack checkpkg checkuri clean cleanall
> cleansstate devpyshell \
> +           devshell listtasks package_index bootimg bundle_initramfs rootfs
> testimage \
> +           testimage_auto compile_kernelmodules diffconfig kernel_checkout
> kernel_configcheck \
> +           kernel_configme kernel_menuconfig kernel_metadata menuconfig
> savedefconfig shared_workdir \
> +           sizecheck strip validate_branches spdx"
> +
> +    colors="auto always never"
> +
> +    case "$cur" in
> +        "--"*)
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    bb_layers_conf="conf/bblayers.conf"
> +    bb_layers_md5=".bb_layers_conf.md5"
> +    bb_recipes=".bb_recipes"
> +
> +    _parse_recipes () {
> +        bitbake -s | sed -e '0,/^=.*/d' -e '/^\s*$/d' -e '/^Summary:/d' |
> awk '{print $1}' > $bb_recipes
> +    }
> +
> +    if [ ! -e $bb_layers_conf ]; then
> +        return 0
> +    fi
> +
> +    if [ "$prev" = "bitbake" -a "$cur" = "" ]; then
> +           _parse_recipes
> +    fi
> +
> +    md5sum --quiet --status -c $bb_layers_md5 2>/dev/null
> +    if [ $? != 0 -o ! -e $bb_recipes ]; then
> +        md5sum $bb_layers_conf > $bb_layers_md5
> +        _parse_recipes
> +    fi
> +
> +    recipes=$(cat $bb_recipes)
> +
> +    case "$prev" in
> +        "-c"|"--color")
> +            COMPREPLY=( $(compgen -W "${colors}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-t"|"--task")
> +          COMPREPLY=( $(compgen -W "${recipes}" -- ${cur}) )
> +          return 0
> +    esac
> +
> +    if [[ ${COMP_WORDS[COMP_CWORD -2]} == "-t" ]] || [[
> ${COMP_WORDS[COMP_CWORD -2]} == "--task" ]]; then
> +        COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
> +           return 0
> +    fi
> +}
> +complete -F _bitbake_diffsigs bitbake-diffsigs
> \ No newline at end of file
> diff --git a/contrib/completion/bash/bitbake_dumpsig_completion
> b/contrib/completion/bash/bitbake_dumpsig_completion
> new file mode 100644
> index 00000000..95eb2394
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_dumpsig_completion
> @@ -0,0 +1,89 @@
> +#!bash
> +# Bash completion support for bitbake-dumpsig tool,
> +# compatible with Bitbake 1.39.1.
> +#
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake_dumpsig()
> +{
> +    local cur prev opts_short opts_long tasks
> +    local bb_layers_conf bb_layers_md5 bb_recipes
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-h -d -t"
> +
> +    opts_long="--help --debug --task="
> +
> +    tasks="build compile compile_ptest_base configure configure_ptest_base
> deploy \
> +           distrodata fetch image image_complete install install_ptest_base
> package \
> +           package_qa package_write_deb package_write_ipk package_write_rpm
> package_write_tar \
> +           packagedata patch populate_lic populate_sdk populate_sysroot
> prepare_recipe_sysroot \
> +           rm_work rm_work_all unpack checkpkg checkuri clean cleanall
> cleansstate devpyshell \
> +           devshell listtasks package_index bootimg bundle_initramfs rootfs
> testimage \
> +           testimage_auto compile_kernelmodules diffconfig kernel_checkout
> kernel_configcheck \
> +           kernel_configme kernel_menuconfig kernel_metadata menuconfig
> savedefconfig shared_workdir \
> +           sizecheck strip validate_branches spdx"
> +
> +    if [[ "$prev" == "=" ]]; then
> +        prev="${COMP_WORDS[COMP_CWORD - 2]}"
> +    elif [[ "$cur" == "=" ]]; then
> +        cur=""
> +    fi
> +
> +    case "$cur" in
> +        "--"*)
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == "--"*"=" ]] ;
> then
> +                compopt -o nospace
> +            fi
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    bb_layers_conf="conf/bblayers.conf"
> +    bb_layers_md5=".bb_layers_conf.md5"
> +    bb_recipes=".bb_recipes"
> +
> +    _parse_recipes () {
> +        bitbake -s | sed -e '0,/^=.*/d' -e '/^\s*$/d' -e '/^Summary:/d' |
> awk '{print $1}' > $bb_recipes
> +    }
> +
> +    if [ ! -e $bb_layers_conf ]; then
> +        return 0
> +    fi
> +
> +    if [ "$prev" = "bitbake" -a "$cur" = "" ]; then
> +           _parse_recipes
> +    fi
> +
> +    md5sum --quiet --status -c $bb_layers_md5 2>/dev/null
> +    if [ $? != 0 -o ! -e $bb_recipes ]; then
> +        md5sum $bb_layers_conf > $bb_layers_md5
> +        _parse_recipes
> +    fi
> +
> +    recipes=$(cat $bb_recipes)
> +
> +    case "$prev" in
> +        "-t"|"--task")
> +           COMPREPLY=( $(compgen -W "${recipes}" -- ${cur}) )
> +           return 0
> +    esac
> +
> +    if [[ ${COMP_WORDS[COMP_CWORD -2]} =~ "-t" ]] || [[
> ${COMP_WORDS[COMP_CWORD -3]} == "--task" ]]; then
> +        COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
> +           return 0
> +    fi
> +}
> +complete -F _bitbake_dumpsig bitbake-dumpsig
> \ No newline at end of file
> diff --git a/contrib/completion/bash/bitbake_layers_completion
> b/contrib/completion/bash/bitbake_layers_completion
> new file mode 100644
> index 00000000..37ca8afb
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_layers_completion
> @@ -0,0 +1,188 @@
> +#!bash
> +# Bash completion support for bitbake-layers tool,
> +# compatible with Bitbake 1.39.1.
> +#
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake_layers()
> +{
> +    local cur prev opts_short opts_long subcommands colors
> +    local opts_long_add_layer opts_short_add_layer opts_long_show_overlayed
> +    local opts_short_show_overlayed opts_long_show_recipes
> opts_short_show_recipes
> +    local opts_long_show_cross_depends opts_short_show_cross_depends
> +    local opts_long_show_layerindex_fetch opts_short_show_layerindex_fetch
> +    local opts_long_show_layerindex_show_depends
> opts_short_show_layerindex_show_depends
> +    local opts_long_show_create_layer opts_short_show_create_layer
> bb_class_files classes
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-d -q -F -h"
> +
> +    opts_long="--debug --quiet --force --color --help"
> +
> +    subcommands="layerindex-fetch layerindex-show-depends add-layer \
> +                    remove-layer flatten show-layers show-overlayed \
> +                        show-recipes show-appends show-cross-depends \
> +                        create-layer"
> +
> +    colors="auto always never"
> +
> +    opts_long_show_overlayed="--help --filenames --same-version"
> +    opts_short_show_overlayed="-h -f -s"
> +
> +    opts_long_show_recipes="--help --filenames --multiple --inherits"
> +    opts_short_show_recipes="-h -f -m -i"
> +
> +    opts_long_show_layerindex_fetch="--help --show-only --branch --ignore"
> +    opts_short_show_layerindex_fetch="-h -n -b -i"
> +
> +    opts_long_add_layer="--help --priority --example-recipe-name
> --example-recipe-version"
> +    opts_short_add_layer="-h"
> +
> +    opts_long_show_cross_depends="--help --filenames --ignore"
> +    opts_short_show_cross_depends="-h -f -i"
> +
> +    opts_long_show_layerindex_show_depends="--help --branch"
> +    opts_short_show_layerindex_show_depends="-h -b"
> +
> +    opts_long_show_create_layer="--help --priority --example-recipe-name
> --example-recipe-version"
> +    opts_short_show_create_layer="-h -p -e -v"
> +
> +    bb_class_files=".bb_class_files"
> +
> +    _get_classes() {
> +        find $BBPATH/../meta*/classes/ -name *.bbclass -exec basename {} \;
> | sed 's/.bbclass//' > $bb_class_files
> +    }
> +
> +    if [[ "${COMP_WORDS[@]}" =~ show-recipes ]] ; then
> +        if [[ "$prev" == "--inherits" ]] || [[ "$prev" == "-i" ]]; then
> +            _get_classes
> +            classes=$(cat $bb_class_files)
> +            COMPREPLY=( $(compgen -W "${classes}" -- ${cur}) )
> +            return 0
> +        fi
> +    fi
> +
> +    if [[ "${COMP_WORDS[1]}" =~
> show-layers|show-appends|remove-layer|flatten ]]; then
> +        case "$cur" in
> +            "--"*)
> +                COMPREPLY=( $(compgen -W "--help" -- ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "-h" -- ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "add-layer" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W "${opts_long_add_layer}" --
> ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "${opts_short_add_layer}" --
> ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "show-overlayed" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W "${opts_long_show_overlayed}" --
> ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "${opts_short_show_overlayed}" --
> ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "show-recipes" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W "${opts_long_show_recipes}" --
> ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "${opts_short_show_recipes}" --
> ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "show-cross-depends" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W "${opts_long_show_cross_depends}"
> -- ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "${opts_short_show_cross_depends}"
> -- ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "layerindex-fetch" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W
> "${opts_long_show_layerindex_fetch}" -- ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W
> "${opts_short_show_layerindex_fetch}" -- ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "layerindex-show-depends" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W
> "${opts_long_show_layerindex_show_depends}" -- ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W
> "${opts_short_show_layerindex_show_depends}" -- ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    elif [[ "${COMP_WORDS[1]}" == "create-layer" ]]; then
> +        case "$cur" in
> +            "--"*|"")
> +                COMPREPLY=( $(compgen -W "${opts_long_show_create_layer}"
> -- ${cur}) )
> +                return 0
> +            ;;
> +            "-"*)
> +                COMPREPLY=( $(compgen -W "${opts_short_show_create_layer}"
> -- ${cur}) )
> +                return 0
> +            ;;
> +        esac
> +    fi
> +
> +    case "$prev" in
> +        "-c"|"--color")
> +            COMPREPLY=( $(compgen -W "${colors}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    case "$cur" in
> +        "--"*)
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    if [[ ${prev} == "bitbake-layers" ]]; then
> +        COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
> +        return 0
> +    elif [[ ! ${subcommands} =~ [[:space:]]${cur}[[:space:]] ]]; then
> +        COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
> +        return 0
> +    fi
> +}
> +complete -F _bitbake_layers bitbake-layers
> \ No newline at end of file
> diff --git a/contrib/completion/bash/bitbake_prserv_completion
> b/contrib/completion/bash/bitbake_prserv_completion
> new file mode 100644
> index 00000000..3bca1197
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_prserv_completion
> @@ -0,0 +1,76 @@
> +#!bash
> +# Bash completion support for bitbake-prserv tool,
> +# compatible with Bitbake 1.39.1.
> +#
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake_prserv()
> +{
> +    local cur prev opts_short opts_long subcommands file_default
> log_default log_levels
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-h -f -l"
> +
> +    opts_long="--version --help --file= --log= --loglevel= --start \
> +                  --stop --host= --port="
> +
> +    subcommands="layerindex-fetch layerindex-show-depends add-layer \
> +                    remove-layer flatten show-layers show-overlayed \
> +                        show-recipes show-appends show-cross-depends \
> +                        create-layer"
> +
> +    file_default="prserv.sqlite3"
> +    log_default="prserv.log"
> +    log_levels="CRITICAL ERROR WARNING INFO DEBUG"
> +
> +    if [[ "$prev" == "=" ]]; then
> +        prev="${COMP_WORDS[COMP_CWORD -2]}"
> +    elif [[ "$cur" == "=" ]]; then
> +        cur=""
> +    fi
> +
> +    case "$prev" in
> +        "-f"|"--file")
> +            COMPREPLY=( $(compgen -W "${file_default}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-l"|"--log")
> +            COMPREPLY=( $(compgen -W "${log_default}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "--loglevel")
> +            COMPREPLY=( $(compgen -W "${log_levels}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    case "$cur" in
> +        "--"*|"")
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == "--"*"=" ]] ;
> then
> +                compopt -o nospace
> +            fi
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +
> +    if [[ ${prev} == "bitbake-layers" ]]; then
> +        COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
> +        return 0
> +    elif [[ ! ${subcommands} =~ [[:space:]]${cur}[[:space:]] ]]; then
> +        COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
> +        return 0
> +    fi
> +}
> +complete -F _bitbake_prserv bitbake-prserv
> \ No newline at end of file
> diff --git a/contrib/completion/bash/bitbake_selftest_completion
> b/contrib/completion/bash/bitbake_selftest_completion
> new file mode 100644
> index 00000000..8b6bf641
> --- /dev/null
> +++ b/contrib/completion/bash/bitbake_selftest_completion
> @@ -0,0 +1,34 @@
> +#!bash
> +# Bash completion support for bitbake-selftest tool,
> +# compatible with Bitbake version 1.39.1.
> +#
> +# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon at gmail.com>
> +#
> +# Distributed under the MIT License (MIT)
> +#
> +
> +_bitbake_selftest()
> +{
> +    local cur prev opts_short opts_long
> +
> +    COMPREPLY=()
> +
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    opts_short="-h -v -q -f -c"
> +
> +    opts_long="--help --verbose --quiet --locals --failfast --catch"
> +
> +    case "$cur" in
> +        "--"*)
> +            COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
> +            return 0
> +        ;;
> +        "-"*)
> +            COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
> +            return 0
> +        ;;
> +    esac
> +}
> +complete -F _bitbake_selftest bitbake-selftest
> \ No newline at end of file
> --
> 2.18.0
>
> --
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>
>



More information about the bitbake-devel mailing list