bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Wed, 09 Dec 2020 23:53:30 +0100
branchv_0
changeset 1 e04e5bbc147b
parent 0 1bb084f84eb9
child 3 ae8775e0bc7a
permissions -rw-r--r--
add --style section-first
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
# Relational pipes
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
# Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
# This program is free software: you can redistribute it and/or modify
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
# it under the terms of the GNU General Public License as published by
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
# the Free Software Foundation, version 3 of the License.
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
#
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
# This program is distributed in the hope that it will be useful,
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
# GNU General Public License for more details.
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
#
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
# You should have received a copy of the GNU General Public License
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
_relpipe_out_ini_completion() {
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
	local w0 w1 w2 w3
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
	COMPREPLY=()
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	w0=${COMP_WORDS[COMP_CWORD]}
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
	w1=${COMP_WORDS[COMP_CWORD-1]}
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	w2=${COMP_WORDS[COMP_CWORD-2]}
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
	w3=${COMP_WORDS[COMP_CWORD-3]}
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
	BOOLEAN_VALUES=(
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
		"true"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
		"false"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
	)
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	STYLES=(
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
		"auto"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
		"dropped"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
		"literal"
1
e04e5bbc147b add --style section-first
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    34
		"section-first"
0
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
		"standard"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	)
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
	DIALECTS=(
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
		"java-properties"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	);
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
	WRITER_OPTIONS=(
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
		"dialect"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
		"comment-separator-for-sections"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
		"comment-separator-for-entries"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		"comment-separator-standalone"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
		"key-value-separator"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
		"escape-backspace"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
		"escape-basic"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
		"escape-java-properties"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
	);
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
	if   [[ "$w1" == "--relation"                                            && "x$w0" == "x" ]];    then COMPREPLY=("''")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
	elif [[ "$w1" == "--style"                                                                ]];    then COMPREPLY=($(compgen -W "${STYLES[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	elif [[ "$w1" == "--writer-option"                                                        ]];    then COMPREPLY=($(compgen -W "${WRITER_OPTIONS[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	elif [[ "$w2" == "--writer-option" && "$w1" == "dialect"                                  ]];    then COMPREPLY=($(compgen -W "${DIALECTS[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
	elif [[ "$w2" == "--writer-option" && "$w1" == "comment-separator-for-sections"           ]];    then COMPREPLY=("' ; '")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	elif [[ "$w2" == "--writer-option" && "$w1" == "comment-separator-for-entries"            ]];    then COMPREPLY=("' ; '")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	elif [[ "$w2" == "--writer-option" && "$w1" == "comment-separator-standalone"             ]];    then COMPREPLY=("'; '")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	elif [[ "$w2" == "--writer-option" && "$w1" == "key-value-separator"                      ]];    then COMPREPLY=("' = '")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
	elif [[ "$w2" == "--writer-option" && "$w1" == "escape-backspace"                         ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
	elif [[ "$w2" == "--writer-option" && "$w1" == "escape-basic"                             ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
	elif [[ "$w2" == "--writer-option" && "$w1" == "escape-java-properties"                   ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
	elif [[ "$w2" == "--writer-option"                                       && "x$w0" == "x" ]];    then COMPREPLY=("''")
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
	else
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
		OPTIONS=(
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
			"--writer-option"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
			"--relation"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
			"--style"
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
		)
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	fi
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
}
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
1bb084f84eb9 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
complete -F _relpipe_out_ini_completion relpipe-out-ini