ajouter le template pour yaml

This commit is contained in:
Jephté Clain 2018-11-08 10:25:44 +04:00
parent e9d0aeebaf
commit 2f86786c94
2 changed files with 16 additions and 3 deletions

View File

@ -25,6 +25,7 @@ EXTS=(
java:java api:wosrccomp wosrc:wosrccomp properties:javaproperties java:java api:wosrccomp wosrc:wosrccomp properties:javaproperties
pp:ppfile pp:ppfile
jgo:javago jgo:javago
yml:yaml yaml:yaml
) )
# Aliases de templates # Aliases de templates
@ -49,7 +50,7 @@ TEMPLATES=(
# Scripts à utiliser pour générer les templates # Scripts à utiliser pour générer les templates
TEMPLS=( TEMPLS=(
text:text conf:text sql:text sieve:text text:text conf:text sql:text sieve:text yaml:text
markdown:wiki tiddlywiki:wiki markdown:wiki tiddlywiki:wiki
puml:plantuml iuml:plantuml puml:plantuml iuml:plantuml
shell:shell shell:shell

View File

@ -23,9 +23,9 @@ OPTIONS
} }
NAME=text NAME=text
TEMPLATES=(text conf sql sieve) TEMPLATES=(text conf sql sieve yaml)
NAMES=() NAMES=()
EXTS=(txt conf sql sieve) EXTS=(txt conf sql sieve yml yaml)
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
if [ "$1" == "--matches-template" ]; then if [ "$1" == "--matches-template" ]; then
@ -102,6 +102,17 @@ function generate_sieve() {
return 0 return 0
} }
function generate_yaml() {
local file="$1"
local mode=yaml
check_overwrite "$1" || return
estep "$(ppath "$file")"
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
[ -n "$2" ] && array_add "$2" "$file"
return 0
}
template= template=
edit=1 edit=1
overwrite= overwrite=
@ -137,6 +148,7 @@ for file in "$@"; do
conf|c) generate_conf "$file" files2edit || r=$?;; conf|c) generate_conf "$file" files2edit || r=$?;;
sql) generate_sql "$file" files2edit || r=$?;; sql) generate_sql "$file" files2edit || r=$?;;
sieve) generate_sieve "$file" files2edit || r=$?;; sieve) generate_sieve "$file" files2edit || r=$?;;
yaml) generate_yaml "$file" files2edit || r=$?;;
*) die "$NAME: template invalide: $t";; *) die "$NAME: template invalide: $t";;
esac esac
done done