-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_dockerrun_completions
95 lines (94 loc) · 3.96 KB
/
_dockerrun_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
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=SC2317
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202304191255-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro
# @@License : WTFPL
# @@ReadME : dockerrun --help
# @@Copyright : Copyright: (c) 2023 Jason Hempstead, Casjays Developments
# @@Created : Wednesday, Apr 19, 2023 12:55 EDT
# @@File : dockerrun
# @@Description : run docker image
# @@Changelog :
# @@TODO : Better documentation
# @@Other :
# @@Resource :
# @@Terminal App : no
# @@sudo/root : no
# @@Template : completions/system
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_dockerrun_completion() {
#####################################################################
local cur prev words cword opts split CONFDIR="" CONFFILE="" SEARCHDIR=""
local SHOW_COMP_OPTS="" SHORTOPTS="" LONGOPTS="" ARRAY="" LIST="" SHOW_COMP_OPTS_SEP=""
#####################################################################
_init_completion || return
#####################################################################
___ls() { ls -A "$1" 2>/dev/null | grep -v '^$' | grep '^' || false; }
___grep() { GREP_COLORS="" grep -shE '^.*=*..*$' "$1" 2>/dev/null | sed 's|"||g' 2>/dev/null | grep '^' || false; }
___findcmd() { find -L "${1:-$CONFDIR/}" -maxdepth ${3:-3} -type ${2:-f} 2>/dev/null | sed 's#'${1:-$CONFDIR}'##g' | grep '^' || return 1; }
#####################################################################
cur="${COMP_WORDS[$COMP_CWORD]}"
prev="${COMP_WORDS[$COMP_CWORD - 1]}"
#####################################################################
CASJAYSDEVDIR="${CASJAYSDEVDIR:-/usr/local/share/CasjaysDev/scripts}"
#####################################################################
CONFFILE="settings.conf"
CONFDIR="$HOME/.config/myscripts/dockerrun"
SEARCHDIR="${CONFDIR:-$HOME/.config/myscripts/dockerrun}/lists"
#####################################################################
SHOW_COMP_OPTS=""
#####################################################################
SHORTOPTS=""
SHORTOPTS+=""
#####################################################################
LONGOPTS="--completions --config --debug --dir --help --options --raw --version "
LONGOPTS+="--network --mount --docker --publish --ports "
#####################################################################
ARRAY="$(grep --no-filename -vsR '#' "$SEARCHDIR" 2>/dev/null)"
ARRAY+=""
#####################################################################
LIST=""
LIST+=""
#####################################################################
if [ "$SHOW_COMP_OPTS" != "" ]; then
SHOW_COMP_OPTS_SEP="${SHOW_COMP_OPTS//,/ }"
compopt -o $SHOW_COMP_OPTS_SEP
fi
#####################################################################
if [[ ${cur} == --* ]]; then
COMPREPLY=($(compgen -W '${LONGOPTS}' -- ${cur}))
elif [[ ${cur} == -* ]]; then
if [ -n "$SHORTOPTS" ]; then
COMPREPLY=($(compgen -W '${SHORTOPTS}' -- ${cur}))
else
COMPREPLY=($(compgen -W '${LONGOPTS}' -- ${cur}))
fi
else
case "${prev:-${COMP_WORDS[1]}}" in
--completions)
prev=""
COMPREPLY=($(compgen -W 'long short list array' -- "$cur"))
;;
--config | --debug | --help | --options | --raw | --version)
COMPREPLY=($(compgen -W '${ARRAY} ${LONGOPTS} ${SHORTOPTS}' -- ${cur}))
return 0
;;
--dir)
prev="dir"
[ "$cword" -le 2 ] && _filedir -d || COMPREPLY=($(compgen -W '${ARRAY}' -- "$cur"))
;;
*)
COMPREPLY=($(compgen -W '${ARRAY}' -- "$cur"))
return 0
;;
esac
fi
#
} &&
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# enable completions
complete -F _dockerrun_completion -o default dockerrun
# ex: ts=2 sw=2 et filetype=sh