File: dput.bash

package info (click to toggle)
dput 1.2.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 38,396 kB
  • sloc: python: 13,102; sh: 162; makefile: 42
file content (88 lines) | stat: -rw-r--r-- 2,677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# bash-completion/dput.bash
# Programmable Bash command completion for ‘dput’ command.
# See the Bash manual “Programmable Completion” section.
#
# This is free software, and you are welcome to redistribute it under
# certain conditions; see the end of this file for copyright
# information, grant of license, and disclaimer of warranty.

_have dput &&
_dput () {
    COMPREPLY=()

    local cur="${COMP_WORDS[COMP_CWORD]}"
    local prev="${COMP_WORDS[COMP_CWORD-1]}"

    local -a options=(
            -D --dinstall
            -H --host-list
            -P --passive
            -U --no-upload-log
            -V --check-version
            -c --config
            -d --debug
            -e --delayed
            -f --force
            -h --help
            -l --lintian
            -o --check-only
            -p --print
            -s --simulate
            -u --unchecked
            -v --version
            )

    local -a config_files=(
            "${XDG_CONFIG_HOME:-$HOME/.config}/dput/dput.cf"
            "$HOME/.dput.cf"
            "/etc/dput.cf"
            )
    local -a hosts
    readarray -t hosts < <( {
            grep --no-filename "^\[.*\]" "${config_files[@]}" \
                2> /dev/null \
                | tr --delete '[]' || /bin/true
            } | grep --invert-match '^DEFAULT$' | sort --unique )

    case "$prev" in
        -e|--delayed)
            local -a delayed_values=( {0..15} )
            readarray -t COMPREPLY < <(
                    compgen -W "${delayed_values[*]}" -- "$cur"
                    )
            ;;
        -c|--config)
            readarray -t COMPREPLY < <( compgen -G "${cur}*" )
            compopt -o filenames
            compopt -o plusdirs
            ;;
        *)
            readarray -t COMPREPLY < <(
                    compgen -G "${cur}*.changes"
                    compgen -G "${cur}*.dsc"
                    compgen -W "${hosts[*]}" -- "$cur"
                    compgen -W "${options[*]}" -- "$cur"
                    )
            compopt -o filenames
            compopt -o plusdirs
            ;;
    esac

    return 0

} && complete -F _dput dput


# Copyright © 2015–2024 Ben Finney <bignose@debian.org>
# Copyright © 2002 Roland Mas <lolando@debian.org>
#
# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3 of that license or any later version.
# No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.

# Local variables:
# coding: utf-8
# mode: shell-script
# End:
# vim: fileencoding=utf-8 filetype=bash :