@@ -8,6 +8,8 @@ function Remove-TerminalIconsTheme {
88 The icon theme to remove.
99 . PARAMETER ColorTheme
1010 The color theme to remove.
11+ . PARAMETER Force
12+ Bypass confirmation messages.
1113 . EXAMPLE
1214 PS> Remove-TerminalIconsTheme -IconTheme MyAwesomeTheme
1315
@@ -33,19 +35,19 @@ function Remove-TerminalIconsTheme {
3335 . NOTES
3436 A theme must not be active in order to be removed.
3537 #>
36- [cmdletbinding ()]
38+ [cmdletbinding (SupportsShouldProcess )]
3739 param (
3840 [ArgumentCompleter ({
39- param ($Command , $Parameter , $WordToComplete , $CommandAst , $FakeBoundParams )
4041 (Get-TerminalIconsIconTheme ).Keys | Sort-Object
4142 })]
4243 [string ]$IconTheme ,
4344
4445 [ArgumentCompleter ({
45- param ($Command , $Parameter , $WordToComplete , $CommandAst , $FakeBoundParams )
4646 (Get-TerminalIconsColorTheme ).Keys | Sort-Object
4747 })]
48- [string ]$ColorTheme
48+ [string ]$ColorTheme ,
49+
50+ [switch ]$Force
4951 )
5052
5153 $currentTheme = Get-TerminalIconsTheme
@@ -57,13 +59,15 @@ function Remove-TerminalIconsTheme {
5759 if (-not (Test-Path $themePath )) {
5860 Write-Error " Could not find theme file [$themePath ]"
5961 } else {
60- if ($userThemeData.Themes.Color.ContainsKey ($ColorTheme )) {
61- $userThemeData.Themes.Color.Remove ($ColorTheme )
62- } else {
63- # We shouldn't be here
64- Write-Error " Color theme [$ColorTheme ] is not registered."
62+ if ($Force -or $PSCmdlet.ShouldProcess ($ColorTheme , ' Remove color theme' )) {
63+ if ($userThemeData.Themes.Color.ContainsKey ($ColorTheme )) {
64+ $userThemeData.Themes.Color.Remove ($ColorTheme )
65+ } else {
66+ # We shouldn't be here
67+ Write-Error " Color theme [$ColorTheme ] is not registered."
68+ }
69+ Remove-Item $themePath - Force
6570 }
66- Remove-Item $themePath - Force
6771 }
6872 } else {
6973 Write-Error (" Color theme [{0}] is active. Please select another theme before removing this it." -f $ColorTheme )
@@ -76,13 +80,15 @@ function Remove-TerminalIconsTheme {
7680 if (-not (Test-Path $themePath )) {
7781 Write-Error " Could not find theme file [$themePath ]"
7882 } else {
79- if ($userThemeData.Themes.Icon.ContainsKey ($IconTheme )) {
80- $userThemeData.Themes.Icon.Remove ($IconTheme )
81- } else {
82- # We shouldn't be here
83- Write-Error " Icon theme [$IconTheme ] is not registered."
83+ if ($Force -or $PSCmdlet.ShouldProcess ($ColorTheme , ' Remove icon theme' )) {
84+ if ($userThemeData.Themes.Icon.ContainsKey ($IconTheme )) {
85+ $userThemeData.Themes.Icon.Remove ($IconTheme )
86+ } else {
87+ # We shouldn't be here
88+ Write-Error " Icon theme [$IconTheme ] is not registered."
89+ }
90+ Remove-Item $themePath - Force
8491 }
85- Remove-Item $themePath - Force
8692 }
8793 } else {
8894 Write-Error (" Icon theme [{0}] is active. Please select another theme before removing this it." -f $IconTheme )
0 commit comments