-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_covid19_completions
123 lines (115 loc) · 4.66 KB
/
_covid19_completions
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
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202201141342-git
# @Author : Jason Hempstead
# @Contact : jason@casjaysdev.pro
# @License : LICENSE.md
# @ReadME : covid19 --help
# @Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @Created : Monday, Jan 24, 2022 01:47 EST
# @File : covid19
# @Description : script to track the covid-19 outbreak
# @TODO :
# @Other :
# @Resource :
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
_covid19() {
___findcmd() { find -L "${1:-$CONFDIR/}" -maxdepth ${3:-3} -type ${2:-f} 2>/dev/null | sed 's#'${1:-$CONFDIR}'##g' | grep '^' || return 1; }
local CASJAYSDEVDIR="${CASJAYSDEVDIR:-/usr/local/share/CasjaysDev/scripts}"
local cur prev words cword opts split
local cur="${COMP_WORDS[$COMP_CWORD]}"
local prev="${COMP_WORDS[$COMP_CWORD - 1]}"
local CONFFILE="settings.conf"
local CONFDIR="$HOME/.config/myscripts/covid19"
local SEARCHDIR="${CONFDIR:-$HOME/.config/myscripts/covid19}"
#local SEARCHCMD="$(___findcmd "$SEARCHDIR/" "d" "1" | sort -u)"
local SHOW_COMP_OPTS=""
local FILEDIR=""
local OPTS=""
local LONGOPTS="--options --config --version --help --dir"
local SHORTOPTS=""
local ARRAY="$(echo "AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BA BW BV BR IO VG BN BG BF BI KH CM CA CV BQ KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE SZ ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KW KG LA LV LB LS LR LY LI LT LU MO MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE NG NU NF KP MK MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS KR SS ES LK BL SH KN LC MF PM VC SD SR SJ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UM VI UG UA AE GB US UY UZ VU VA VE VN WF EH YE ZM ZW" | tr '[A-Z]' '[a-z]')"
_init_completion || return
if [[ "$SHOW_COMP_OPTS" != "" ]]; then
local SHOW_COMP_OPTS_SEP="${SHOW_COMP_OPTS//,/ }"
compopt -o $SHOW_COMP_OPTS_SEP
fi
if [[ ${cur} == --* ]]; then
COMPREPLY=($(compgen -W '${LONGOPTS}' -- ${cur}))
return
elif [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W '${SHORTOPTS}' -- ${cur}))
return
else
case "${COMP_WORDS[1]:-$prev}" in
--options)
local prev="--options"
COMPREPLY=($(compgen -W '' -- "${cur}"))
;;
--config)
local prev="--config"
COMPREPLY=($(compgen -W '' -- "${cur}"))
;;
--help)
prev="--help"
COMPREPLY=($(compgen -W '' -- "${cur}"))
;;
--version)
local prev="--version"
COMPREPLY=($(compgen -W '' -- "${cur}"))
;;
--dir)
local prev="dir"
_filedir
return
;;
*)
if [[ -n "$FILEDIR" ]]; then _filedir; fi
# if [[ $cword -gt 2 ]]; then
# return
# elif [[ $cword == 2 ]]; then
# _filedir
# compopt -o nospace
# return
# elif [[ $cword -eq 1 ]]; then
# COMPREPLY=($(compgen -W '{a..z}{a..z}' -- "${cur}"))
# compopt -o nospace
# return
if [[ "$ARRAY" = "show__none" ]]; then
COMPREPLY=($(compgen -W '' -- "${cur}"))
elif [[ "$ARRAY" = "show__filedir" ]]; then
_filedir
elif [[ "$ARRAY" = "show__commands" ]]; then
COMPREPLY=($(compgen -c -- "${cur}"))
elif [ "$ARRAY" != "" ]; then
COMPREPLY=($(compgen -W '${ARRAY}' -- "${cur}"))
elif [ -n "$OPTS" ]; then
COMPREPLY=($(compgen -W '${OPTS}' -- "${cur}"))
else
COMPREPLY=($(compgen -W '${ARRAY}' -- "${cur}"))
# elif [[ $cword -gt 2 ]]; then
# return
# elif [[ $cword == 2 ]]; then
# _filedir
# compopt -o nospace
# return
# elif [[ $cword -eq 1 ]]; then
# COMPREPLY=($(compgen -W '{a..z}{a..z}' -- "${cur}"))
# compopt -o nospace
# return
fi
;;
esac
fi
#
# [[ ${cword} == 2 ]] && _filedir && compopt -o nospace
# [[ $COMP_CWORD -eq 2 ] && COMPREPLY=($(compgen -W '{a..z} {A..Z} {0..9}' -o nospace -- "${cur}"))
# [[ $COMP_CWORD -eq 3 ] && COMPREPLY=($(compgen -W '$(_filedir)' -o filenames -o dirnames -- "${cur}"))
# [[ $COMP_CWORD -gt 3 ] && COMPREPLY=($(compgen -W '' -- "${cur}"))
#prev=""
#compopt -o nospace
$split && return
} &&
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# enable completions
complete -F _covid19 covid19