Clean: Install - Separated set custom method

This commit is contained in:
alstjr7375 2022-04-22 15:01:29 +09:00
parent ac51fa2753
commit 352616c87d
2 changed files with 70 additions and 62 deletions

View file

@ -678,10 +678,43 @@ function Copy-CustomFiles() {
}
}
$customFileApplied = $false
$customMethod = ""
$customReset = $false
$customAppend = $false
function Set-CustomMethod() {
$local:menuAppend="Append - Maintain changes in existing files and apply custom"
$local:menuOverwrite="Overwrite - After initializing the change, apply only custom"
$local:menuNone="None - Maintain changes in existing files"
$local:menuReset="Reset- Reset to pure lepton theme without custom"
Write-Host "Select custom method"
while ( "${customMethod}" -eq "" ) {
$local:applyMethod = Menu @("${menuAppend}", "${menuOverwrite}", "${menuNone}", "${menuReset}")
switch ( $applyMethod ) {
"${menuAppend}" {
$global:customMethod = "Append"
$global:customAppend = $true
}
"${menuOverwrite}" {
$global:customMethod = "Overwrite"
$global:customReset = $true
$global:customAppend = $true
}
"${menuNone}" {
$global:customMethod = "None"
}
"${menuReset}" {
$global:customMethod = "Reset"
$global:customReset = $true
}
default { Write-Host "Invalid option, reselect please." }
}
}
Lepton-OKMessage "Selected ${customMethod}"
}
$customFileApplied = $false
function Apply-CustomFile() {
Param (
[Parameter(Mandatory=$true, Position=0)]
@ -698,36 +731,7 @@ function Apply-CustomFile() {
$global:customFileApplied = $true
if ( "${customMethod}" -eq "" ) {
$local:menuAppend="Append - Maintain changes in existing files and apply custom"
$local:menuOverwrite="Overwrite - After initializing the change, apply only custom"
$local:menuNone="None - Maintain changes in existing files"
$local:menuReset="Reset- Reset to pure lepton theme without custom"
Write-Host "Select custom method"
while ( "${customMethod}" -eq "" ) {
$local:applyMethod = Menu @("${menuAppend}", "${menuOverwrite}", "${menuNone}", "${menuReset}")
switch ( $applyMethod ) {
"${menuAppend}" {
$global:customMethod = "Append"
$global:customAppend = $true
}
"${menuOverwrite}" {
$global:customMethod = "Overwrite"
$global:customReset = $true
$global:customAppend = $true
}
"${menuNone}" {
$global:customMethod = "None"
}
"${menuReset}" {
$global:customMethod = "Reset"
$global:customReset = $true
}
default { Write-Host "Invalid option, reselect please." }
}
}
Lepton-OKMessage "Selected ${customMethod}"
Set-CustomMethod
}
if ( "${customReset}" -eq $true ) {

View file

@ -657,10 +657,43 @@ copy_custom_files() {
fi
}
customFileApplied=""
customMethod=""
customReset=""
customAppend=""
set_custom_method() {
local menuAppend="Append - Maintain changes in existing files and apply custom"
local menuOverwrite="Overwrite - After initializing the change, apply only custom"
local menuNone="None - Maintain changes in existing files"
local menuReset="Reset- Reset to pure lepton theme without custom"
echo "Select custom method"
select applyMethod in "${menuAppend}" "${menuOverwrite}" "${menuNone}" "${menuReset}"; do
case "${applyMethod}" in
"${menuAppend}")
customMethod="Append"
customAppend="true"
break;;
"${menuOverwrite}")
customMethod="Overwrite"
customReset="true"
customAppend="true"
break;;
"${menuNone}")
customMethod="None"
break;;
"${menuReset}")
customMethod="Reset"
customReset="true"
break;;
*)
echo "Invalid option, reselect please.";;
esac
done
lepton_ok_message "Selected ${customMethod}"
}
customFileApplied=""
apply_custom_file() {
local gitDir=$1
local targetFile=$2
@ -671,36 +704,7 @@ apply_custom_file() {
customFileApplied="true"
if [ -z "${customMethod}" ]; then
local menuAppend="Append - Maintain changes in existing files and apply custom"
local menuOverwrite="Overwrite - After initializing the change, apply only custom"
local menuNone="None - Maintain changes in existing files"
local menuReset="Reset- Reset to pure lepton theme without custom"
echo "Select custom method"
select applyMethod in "${menuAppend}" "${menuOverwrite}" "${menuNone}" "${menuReset}"; do
case "${applyMethod}" in
"${menuAppend}")
customMethod="Append"
customAppend="true"
break;;
"${menuOverwrite}")
customMethod="Overwrite"
customReset="true"
customAppend="true"
break;;
"${menuNone}")
customMethod="None"
break;;
"${menuReset}")
customMethod="Reset"
customReset="true"
break;;
*)
echo "Invalid option, reselect please.";;
esac
done
lepton_ok_message "Selected ${customMethod}"
set_custom_method
fi
if [ "${customReset}" == "true" ]; then