ufile: ajout des options --list et --edit
This commit is contained in:
parent
a99f313014
commit
151433b85c
27
ufile
27
ufile
|
@ -15,15 +15,40 @@ USAGE
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-n, --fake
|
-n, --fake
|
||||||
Afficher les opérations qui seraient faites"
|
Afficher les opérations qui seraient faites
|
||||||
|
-l, --list
|
||||||
|
Lister les règles définies
|
||||||
|
-e, --edit
|
||||||
|
Lancer un éditeur pour mettre à jour les règles"
|
||||||
}
|
}
|
||||||
|
|
||||||
args=(%
|
args=(%
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
-n,--fake fake=1
|
-n,--fake fake=1
|
||||||
|
-l,--list action=list
|
||||||
|
-e,--edit action=edit
|
||||||
|
--file action=file
|
||||||
)
|
)
|
||||||
parse_args "$@"; set -- "${args[@]}"
|
parse_args "$@"; set -- "${args[@]}"
|
||||||
|
|
||||||
|
[ -n "$action" ] || action=file
|
||||||
|
|
||||||
|
if [ "$action" == list ]; then
|
||||||
|
array_to_lines RULES
|
||||||
|
exit 0
|
||||||
|
elif [ "$action" == edit ]; then
|
||||||
|
setx ufile=get_user_defaults_file ufile
|
||||||
|
if [ ! -f "$ufile" ]; then
|
||||||
|
einfo "Le fichier $(ppath "$ufile") n'existe pas. Il sera créé avec un contenu par défaut"
|
||||||
|
mkdirof "$ufile" || die
|
||||||
|
cp "$scriptdir/lib/defaults/ufile" "$ufile"
|
||||||
|
fi
|
||||||
|
"${EDITOR:-vi}" "$ufile"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$action" == file ] || die "bug: $action: action non implémentée"
|
||||||
|
|
||||||
if [ -n "$fake" ]; then
|
if [ -n "$fake" ]; then
|
||||||
function docmd() { qvals "$@"; }
|
function docmd() { qvals "$@"; }
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue