implémenter l'option -p avec edit_cmd()
This commit is contained in:
parent
a0752e9d94
commit
2b1ad2b531
74
pff
74
pff
|
@ -61,10 +61,35 @@ function __pfs_completion() {
|
||||||
COMPREPLY=($(compgen -W "$(__pff_profiles)" "$cur"))
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" "$cur"))
|
||||||
}
|
}
|
||||||
complete -F __pfs_completion -o bashdefault -o default pfs
|
complete -F __pfs_completion -o bashdefault -o default pfs
|
||||||
|
function __pfe_completion() {
|
||||||
|
local cur prev opt comp
|
||||||
|
_get_comp_words_by_ref cur prev
|
||||||
|
if [[ "$prev" == -*p ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
|
elif [ "$prev" == --profile ]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
|
elif [[ "$cur" == -*p* ]]; then
|
||||||
|
comp="${cur#-*p}"; opt="${cur:0:$((${#cur}-${#comp}))}"
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles "$opt")" -- "$cur"))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
complete -F __pfe_completion -o bashdefault -o default pfe
|
||||||
function __pff_completion() {
|
function __pff_completion() {
|
||||||
local cur prev opt comp
|
local cur prev opt comp
|
||||||
_get_comp_words_by_ref cur prev
|
_get_comp_words_by_ref cur prev
|
||||||
if [[ "$prev" == -*s ]]; then
|
if [ "${COMP_WORDS[1]}" == -e -o "${COMP_WORDS[1]}" == --edit ]; then
|
||||||
|
# ne compléter -p que si on est en mode --edit
|
||||||
|
if [[ "$prev" == -*p ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
|
elif [ "$prev" == --profile ]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
|
elif [[ "$cur" == -*p* ]]; then
|
||||||
|
comp="${cur#-*p}"; opt="${cur:0:$((${#cur}-${#comp}))}"
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles "$opt")" -- "$cur"))
|
||||||
|
fi
|
||||||
|
elif [[ "$prev" == -*s ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
|
elif [ "$prev" == --switch ]; then
|
||||||
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
COMPREPLY=($(compgen -W "$(__pff_profiles)" -- "$cur"))
|
||||||
elif [[ "$cur" == -*s* ]]; then
|
elif [[ "$cur" == -*s* ]]; then
|
||||||
comp="${cur#-*s}"; opt="${cur:0:$((${#cur}-${#comp}))}"
|
comp="${cur#-*s}"; opt="${cur:0:$((${#cur}-${#comp}))}"
|
||||||
|
@ -207,6 +232,9 @@ supportées sont:
|
||||||
et le fichier D du profil test.
|
et le fichier D du profil test.
|
||||||
Si cette option est utilisée pour sélectionner un fichier dans un autre
|
Si cette option est utilisée pour sélectionner un fichier dans un autre
|
||||||
profil, le profil courant est restauré à la fin de la commande.
|
profil, le profil courant est restauré à la fin de la commande.
|
||||||
|
Attention: pour que l'option -p/--profile soit correctement reconnue
|
||||||
|
avec l'option -e/--edit, il faut que cette dernière option soit
|
||||||
|
mentionnée en premier sur la ligne de commande.
|
||||||
|
|
||||||
-d, --diff [DESTP [WORKDIR]]
|
-d, --diff [DESTP [WORKDIR]]
|
||||||
-d, --diff [SRCP DESTP [WORKDIR]]
|
-d, --diff [SRCP DESTP [WORKDIR]]
|
||||||
|
@ -820,7 +848,7 @@ function new_cmd() {
|
||||||
# pff --patch
|
# pff --patch
|
||||||
|
|
||||||
function patch_cmd() {
|
function patch_cmd() {
|
||||||
local pffdir="$1"
|
local commit="$1" pffdir="$2"
|
||||||
|
|
||||||
ensure_pffdir pffdir "$pffdir"
|
ensure_pffdir pffdir "$pffdir"
|
||||||
}
|
}
|
||||||
|
@ -996,16 +1024,26 @@ function add_local_cmd() {
|
||||||
# pff --edit
|
# pff --edit
|
||||||
|
|
||||||
function edit_cmd() {
|
function edit_cmd() {
|
||||||
local pffdir file rfile pfile Pfile
|
local profile="$1"; shift
|
||||||
local profile r
|
local pffdir file rfile pfile Pfile r
|
||||||
local -a edits
|
local -a edits args
|
||||||
|
|
||||||
ensure_pffdir pffdir
|
ensure_pffdir pffdir
|
||||||
setx profile=get_current_profile "$pffdir"
|
[ -n "$profile" ] || setx profile=get_current_profile "$pffdir"
|
||||||
enote "Edition des fichiers dans le profil $profile"
|
enote "Dans le profil $profile:"
|
||||||
|
|
||||||
r=0
|
r=0
|
||||||
for file in "$@"; do
|
while [ $# -gt 0 ]; do
|
||||||
|
if [[ "$1" == -* ]]; then
|
||||||
|
# nouvelle option
|
||||||
|
local prev_profile="$profile"
|
||||||
|
args=(+ -p:,--profile: profile=)
|
||||||
|
parse_args "$@"; set -- "${args[@]}"
|
||||||
|
[ "$profile" != "$prev_profile" ] && enote "Dans le profil $profile:"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
file="$1"; shift
|
||||||
|
|
||||||
if [ -d "$file" ]; then
|
if [ -d "$file" ]; then
|
||||||
ewarn "$file: est un répertoire. argument ignoré"
|
ewarn "$file: est un répertoire. argument ignoré"
|
||||||
continue
|
continue
|
||||||
|
@ -1022,6 +1060,7 @@ function edit_cmd() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
setx Pfile=get_pfile "$pfile" "$profile" "$pffdir"
|
setx Pfile=get_pfile "$pfile" "$profile" "$pffdir"
|
||||||
|
estep "Edition de $(ppath "$Pfile")"
|
||||||
array_add edits "$Pfile"
|
array_add edits "$Pfile"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1176,6 +1215,11 @@ done
|
||||||
QUIET=1 # masquer les messages de git et rsync?
|
QUIET=1 # masquer les messages de git et rsync?
|
||||||
VERYQUIET=1 # masquer les messages de git commit?
|
VERYQUIET=1 # masquer les messages de git commit?
|
||||||
|
|
||||||
|
parse_mode=
|
||||||
|
if [ "$1" == -e -o "$1" == --edit ]; then
|
||||||
|
parse_mode=+
|
||||||
|
fi
|
||||||
|
|
||||||
action=infos
|
action=infos
|
||||||
autopatch=1
|
autopatch=1
|
||||||
version=
|
version=
|
||||||
|
@ -1183,8 +1227,10 @@ disttype=auto
|
||||||
ORIGEXTS=("${DEFAULT_ORIGEXTS[@]}")
|
ORIGEXTS=("${DEFAULT_ORIGEXTS[@]}")
|
||||||
PROTECTS=("${DEFAULT_PROTECTS[@]}")
|
PROTECTS=("${DEFAULT_PROTECTS[@]}")
|
||||||
unwrap=auto
|
unwrap=auto
|
||||||
|
commit=ask
|
||||||
|
profile=
|
||||||
alternate=
|
alternate=
|
||||||
args=(
|
args=($parse_mode
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
-0,--init action=init
|
-0,--init action=init
|
||||||
--s:,--origext: '$add@ ORIGEXTS'
|
--s:,--origext: '$add@ ORIGEXTS'
|
||||||
|
@ -1198,13 +1244,17 @@ args=(
|
||||||
--auto-unwrap unwrap=auto
|
--auto-unwrap unwrap=auto
|
||||||
--no-unwrap unwrap=
|
--no-unwrap unwrap=
|
||||||
-E,--unwrap unwrap=1
|
-E,--unwrap unwrap=1
|
||||||
-p,--patch action=patch
|
--patch action=patch
|
||||||
|
--ask-commit commit=ask
|
||||||
|
-c,--comit commit=1
|
||||||
|
--no-commit commit=
|
||||||
-a,--add-global action=add-global
|
-a,--add-global action=add-global
|
||||||
--locals action=list-locals
|
--locals action=list-locals
|
||||||
--profiles action=list-profiles
|
--profiles action=list-profiles
|
||||||
-s,--switch action=switch
|
-s,--switch action=switch
|
||||||
-b,--add-local action=add-local
|
-b,--add-local action=add-local
|
||||||
-e,--edit action=edit
|
-e,--edit action=edit
|
||||||
|
-p:,--profile: profile=
|
||||||
-d,--diff action=diff
|
-d,--diff action=diff
|
||||||
--infos action=infos
|
--infos action=infos
|
||||||
-l,--list-names,--show-all alternate=1
|
-l,--list-names,--show-all alternate=1
|
||||||
|
@ -1216,13 +1266,13 @@ array_fix_paths ORIGEXTS
|
||||||
case "$action" in
|
case "$action" in
|
||||||
init) init_cmd "$@";;
|
init) init_cmd "$@";;
|
||||||
new) new_cmd "$autopatch" "$version" "$disttype" "$unwrap" "$@";;
|
new) new_cmd "$autopatch" "$version" "$disttype" "$unwrap" "$@";;
|
||||||
patch) patch_cmd "$@";;
|
patch) patch_cmd "$commit" "$@";;
|
||||||
add-global) add_global_cmd "$@";;
|
add-global) add_global_cmd "$@";;
|
||||||
list-locals) list_locals_cmd "$@";;
|
list-locals) list_locals_cmd "$@";;
|
||||||
list-profiles) list_profiles_cmd "$@";;
|
list-profiles) list_profiles_cmd "$@";;
|
||||||
switch) switch_cmd "$@";;
|
switch) switch_cmd "$@";;
|
||||||
add-local) add_local_cmd "$@";;
|
add-local) add_local_cmd "$@";;
|
||||||
edit) edit_cmd "$@";;
|
edit) edit_cmd "$profile" "$@";;
|
||||||
diff) diff_cmd "$alternate" "$@";;
|
diff) diff_cmd "$alternate" "$@";;
|
||||||
infos) infos_cmd "$alternate" "$@";;
|
infos) infos_cmd "$alternate" "$@";;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue