From a61452c8166ad13e3978c310ba9ad5167cf1008d Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 7 Feb 2018 17:23:47 +0400 Subject: [PATCH] =?UTF-8?q?pff:=20enregistrer=20les=20profils=20d=C3=A9fin?= =?UTF-8?q?is=20et=20les=20cr=C3=A9er=20sans=20confirmation=20si=20n=C3=A9?= =?UTF-8?q?cessaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pff | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pff b/pff index 862683b..5cbd3e6 100755 --- a/pff +++ b/pff @@ -18,6 +18,7 @@ PFFCONFVARS=( "VERSION//Version actuellement installée" -a "PVERSIONS//Versions en attente d'intégration" + "PROFILES//Profils définis" "ORIGEXTS=//Extensions origines" ) @@ -268,7 +269,8 @@ function get_current_profile() { function get_profiles() { # afficher tous les profils valides du projet pff $1 local pffdir="$1" - list_dirs "$pffdir/pff" | grep -vxF Current + (for profile in "${PROFILES[@]}"; do echo "$profile"; done + list_dirs "$pffdir/pff") | sort -u | grep -vxF Current } function get_first_profile() { @@ -339,6 +341,7 @@ function get_cfile() { get_pfile "$1" Current "$2"; } function get_vlfiles() { # afficher tous les fichiers de version local pffdir="$1" rfile="$2" profile="${3:-Base}" + [ -d "$pffdir/pff/$profile" ] || return if [ -n "$rfile" ]; then find "$pffdir/pff/$profile" \ -type f -path "$pffdir/pff/$profile/${rfile}__pv-*__" -o \ @@ -879,8 +882,13 @@ function switch_cmd() { autoinit "$pffdir" setx -a profiles=get_profiles "$pffdir" if ! array_contains profiles "$profile"; then - ewarn "$profile: ce profil n'existe pas" - ask_yesno "Voulez-vous le créer?" O || return 1 + if ! array_contains PROFILES "$profile"; then + ewarn "$profile: ce profil n'existe pas" + ask_yesno "Voulez-vous le créer?" O || return 1 + + array_addu PROFILES "$profile" + conf_update "$pffdir/$PFFCONF" PROFILES + fi fi enote "Sélection du profil $profile" select_profile "$profile" "$pffdir" @@ -1092,7 +1100,7 @@ function infos_cmd() { setx -a profiles=get_profiles "$pffdir" if [ ${#lfiles[*]} -gt 0 ]; then - [ ${#lfiles[*]} -gt 1 ] && estep "${#lfiles[*]} fichiers locaux:" || estep "1 fichier local:" + [ ${#lfiles[*]} -gt 1 ] && estep "${#lfiles[*]} fichiers locaux" || estep "1 fichier local" for rfile in "${lfiles[@]}"; do setx -a vlfiles=get_vlfiles "$pffdir" "$rfile" "$profile" setx Pfile=get_pfile "$pffdir/$rfile" "$profile" "$pffdir"