Commit ed0caf0b authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue

[_cranspasswords] Améliorations + découpage du gros bloc central

parent 7a2b4a45
......@@ -7,72 +7,84 @@ _cranspasswords(){
cmd=$words[$END]
case $cmd in
--server)
liste_serveurs=($(cranspasswords --list-servers 2> /dev/null | tail -n +2 | awk '{print $2}' | tr '\n' ' '))
for i in $liste_serveurs; do
_wanted server expl "server names" compadd $i;
done;
_cranspasswords_servers
;;
--view | --edit)
pos=$words[(i)--server]
posa=$(( pos + 1))
if (( posa < $#words )); then
fname="cpw_$words[$posa]_files"
server=$words[$posa]
else
fname="cpw_default_files"
server="default"
fi;
result=$(find /tmp -mmin -1 -name $fname 2> /dev/null | wc -l)
if (( result < 1 )); then
liste_fichiers=($(cranspasswords --server $server --list 2>/dev/null | tail -n +2 | head -n -1 | awk '{print $2}' | tr '\n' ' '))
echo $liste_fichiers > /tmp/$fname
for i in $liste_fichiers; do
_wanted files expl "file names" compadd $i;
done;
else
liste_fichiers=($(cat /tmp/$fname))
for i in $liste_fichiers; do
_wanted files expl "file names" compadd $i;
done;
fi;
_cranspasswords_files
;;
--roles)
pos=$words[(i)--server]
posa=$(( pos + 1))
if (( posa < $#words )); then
fname="cpw_$words[$posa]_roles"
server=$words[$posa]
else
fname="cpw_default_roles"
server="default"
fi;
result=$(find /tmp -mmin -1 -name $fname 2> /dev/null | wc -l)
if (( result < 1 )); then
liste_fichiers=($(cranspasswords --server $server --list-roles 2>/dev/null | tail -n +2 | awk '{print $2}' | tr '\n' ' '))
echo $liste_fichiers > /tmp/$fname
for i in $liste_fichiers; do
_wanted roles expl "role names" compadd $i;
done;
else
liste_fichiers=($(cat /tmp/$fname))
for i in $liste_fichiers; do
_wanted roles expl "role names" compadd $i;
done;
fi;
_cranspasswords_roles
;;
*)
_cranspasswords_args $@
_cranspasswords_args
;;
esac
else
_cranspasswords_args $@
_cranspasswords_files
fi
}
_cranspasswords_files(){
pos=$words[(i)--server]
posa=$(( pos + 1))
if (( posa < $#words )); then
fname="cpw_$words[$posa]_files"
server=$words[$posa]
else
fname="cpw_default_files"
server="default"
fi;
result=$(find /tmp -mmin -1 -name $fname 2> /dev/null | wc -l)
if (( result < 1 )); then
liste_fichiers=($(cranspasswords --server $server --list 2>/dev/null | tail -n +2 | head -n -1 | awk '{print $2}' | tr '\n' ' '))
echo $liste_fichiers > /tmp/$fname
for i in $liste_fichiers; do
_wanted files expl "file names" compadd $i;
done;
else
liste_fichiers=($(cat /tmp/$fname))
for i in $liste_fichiers; do
_wanted files expl "file names" compadd $i;
done;
fi;
}
_cranspasswords_roles(){
pos=$words[(i)--server]
posa=$(( pos + 1))
if (( posa < $#words )); then
fname="cpw_$words[$posa]_roles"
server=$words[$posa]
else
fname="cpw_default_roles"
server="default"
fi;
result=$(find /tmp -mmin -1 -name $fname 2> /dev/null | wc -l)
if (( result < 1 )); then
liste_fichiers=($(cranspasswords --server $server --list-roles 2>/dev/null | tail -n +2 | awk '{print $2}' | tr '\n' ' '))
echo $liste_fichiers > /tmp/$fname
for i in $liste_fichiers; do
_wanted roles expl "role names" compadd $i;
done;
else
liste_fichiers=($(cat /tmp/$fname))
for i in $liste_fichiers; do
_wanted roles expl "role names" compadd $i;
done;
fi;
}
_cranspasswords_servers(){
liste_serveurs=($(cranspasswords --list-servers 2> /dev/null | tail -n +2 | awk '{print $2}' | tr '\n' ' '))
for i in $liste_serveurs; do
_wanted server expl "server names" compadd $i;
done;
}
_cranspasswords_args(){
_arguments -s : \
"(-h --help)"{-h,--help}"[Obtenir de l'aide]" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment