pff: support ---clean-switch

This commit is contained in:
Jephté Clain 2025-04-14 12:33:18 +04:00
parent 634335a692
commit b42f9df5d3

11
pff
View File

@ -1505,10 +1505,17 @@ function list_profiles_cmd() {
# pff --switch
function switch_cmd() {
local clean=
if [ "$1" == --clean ]; then
shift
clean=1
fi
local profile="$1" pffdir="$2"
local -a profiles
ensure_pffdir pffdir "$pffdir"
[ -n "$clean" ] && rm -rf "$pffdir/pff/Current"
autoinit "$pffdir"
[ -n "$profile" ] || setx profile=get_first_profile "$pffdir"
@ -1842,6 +1849,7 @@ merge_strategy=
commit_policy=ask
profile=
alternate=
clean_switch=
args=($parse_mode
--help '$exit_with display_help'
-0,--init action=init
@ -1867,6 +1875,7 @@ args=($parse_mode
--locals action=list-locals
--profiles action=list-profiles
-s,--switch action=switch
--sk,--clean-switch clean_switch=1
-a,--add-local action=add-local
-e,--edit action=edit
-p:,--profile: profile=
@ -1888,7 +1897,7 @@ patch) patch_cmd "$merge_strategy" "$commit_policy" "$@";;
add-global) add_global_cmd "$@";;
list-locals) list_locals_cmd "$@";;
list-profiles) list_profiles_cmd "$@";;
switch) switch_cmd "$@";;
switch) switch_cmd ${clean_switch:+--clean} "$@";;
add-local) add_local_cmd "$@";;
edit) edit_cmd "$profile" "$@";;
diff) diff_cmd "$alternate" "$@";;