-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbash_completion
136 lines (124 loc) · 3.48 KB
/
bash_completion
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
_complete_subcommands() {
local subcommands="add-template-redirects all-headers dump-parsed-templates dump-templates filter-headers help";
COMPREPLY=($(compgen -W "${subcommands}" -- "${1}"));
}
_complete_dump_options() {
case "${1}" in
-n | --namespaces)
local namespaces=namespaces="appendix appendix_talk category category_talk citations citations_talk concordance concordance_talk file file_talk gadget gadget_definition gadget_definition_talk gadget_talk help help_talk index index_talk main media mediawiki mediawiki_talk module module_talk reconstruction reconstruction_talk rhymes rhymes_talk sign_gloss sign_gloss_talk special summary summary_talk talk template template_talk thesaurus thesaurus_talk thread thread_talk transwiki transwiki_talk user user_talk wiktionary wiktionary_talk";
COMPREPLY=($(compgen -W "${namespaces}" -- "${2##*,}"));
return 0;
;;
-i | --input)
COMPREPLY=($(compgen -f -X '!*.xml' -- "${2}"));
compopt -o nospace -o dirnames;
return 0;
;;
*)
;;
esac;
return 1;
}
_wiktionary_dump2()
{
local i cur prev opts cmds subcommand;
COMPREPLY=();
cur="${COMP_WORDS[COMP_CWORD]}";
prev="${COMP_WORDS[COMP_CWORD-1]}";
for i in ${!COMP_WORDS[@]};
do
case "${COMP_WORDS[${i}]}" in
wiktionary_dump2)
subcommand="${COMP_WORDS[${i}+1]}";
break;
;;
*)
;;
esac;
done;
# if second word, complete subcommands
if [[ ${COMP_CWORD} -eq 1 ]]; then
_complete_subcommands "${cur}";
return 0;
fi;
case "${subcommand}" in
add-template-redirects)
opts="--help --suffix --version -V -h -s <files>...";
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"));
return 0;
;;
all-headers)
if _complete_dump_options "${prev}" "${cur}"; then
return 0;
fi
opts="--help --input --namespaces --pages --pretty --version -P -V -h -i -n -p";
;;
dump-parsed-templates)
if _complete_dump_options "${prev}" "${cur}"; then
return 0;
fi
case "${prev}" in
-f | --format)
local formats="json cbor";
COMPREPLY=($(compgen -W "${formats}" -- "${cur}"));
return 0;
;;
-t | --templates)
COMPREPLY=($(compgen -f -X "!*template*.txt" -- "${cur}"))
compopt -o nospace -o dirnames;
return 0;
;;
*)
;;
esac;
opts="--format --help --input --namespaces --pages --templates --version -V -f -h -i -n -p -t";
;;
dump-templates)
if _complete_dump_options "${prev}" "${cur}"; then
return 0;
fi
case "${prev}" in
-t | --templates)
COMPREPLY=($(compgen -f -X "!*template*.txt" -- "${cur}"))
compopt -o nospace -o dirnames;
return 0;
;;
*)
;;
esac;
opts="--help --input --namespaces --pages --templates --version -V -h -i -n -p -t";
;;
filter-headers)
if _complete_dump_options "${prev}" "${cur}"; then
return 0;
fi
case "${prev}" in
-o | --other_headers)
COMPREPLY=($(compgen -f -X "!*headers.txt" -- "${cur}"));
compopt -o nospace -o dirnames;
return 0;
;;
-t | --top_level_header)
COMPREPLY=($(compgen -f -X "!language*.txt" -o dirnames -- "${cur}"));
compopt -o nospace -o dirnames;
return 0;
;;
*)
;;
esac;
opts="--help --input --namespaces --other --pages --pretty --top --version -P -V -h -i -n -o -p -t";
;;
help)
_complete_subcommands "${cur}";
return 0;
;;
*)
COMPREPLY=();
return 0;
;;
esac;
# opts set above
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"));
return 0;
}
complete -F _wiktionary_dump2 -o bashdefault -o default wiktionary_dump2