From a0f988b24214c14724c67570d2210073b15f085b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Oct 2025 00:26:04 +0000 Subject: [PATCH 01/11] Initial plan From 8d8483c5703cc7d3d3add30b5c0dcf748bef4384 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Oct 2025 00:32:41 +0000 Subject: [PATCH 02/11] Add NewTipsOnly cadence to WritePowerShellTipCadence enum Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- .../tiPSClasses/Configuration.cs | 3 +- ...maticWritePowerShellTipFunctions.Tests.ps1 | 69 +++++++++++++++++++ .../AutomaticWritePowerShellTipFunctions.ps1 | 29 ++++++++ src/tiPS/Public/Set-TiPSConfiguration.ps1 | 3 +- 4 files changed, 102 insertions(+), 2 deletions(-) diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index 95dd6d3..a94f512 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -16,7 +16,8 @@ public enum WritePowerShellTipCadence Daily = 2, Weekly = 3, Biweekly = 4, - Monthly = 5 + Monthly = 5, + NewTipsOnly = 6 } public enum TipRetrievalOrder diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 3196ba0..c88c60e 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -141,6 +141,28 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi Assert-MockCalled WriteAutomaticPowerShellTip -Times 0 -Exactly } } + + Context 'When the WritePowerShellTipCadence is NewTipsOnly' { + It 'Should show a tip when there are unseen tips' { + $config = [tiPS.Configuration]::new() + $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::NewTipsOnly + Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } + + WriteAutomaticPowerShellTipIfNeeded -Config $config + + Assert-MockCalled WriteAutomaticPowerShellTip -Times 1 -Exactly + } + + It 'Should not show a tip when all tips have been shown' { + $config = [tiPS.Configuration]::new() + $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::NewTipsOnly + Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } + + WriteAutomaticPowerShellTipIfNeeded -Config $config + + Assert-MockCalled WriteAutomaticPowerShellTip -Times 0 -Exactly + } + } } Describe 'Calling WriteLastAutomaticTipWrittenDate' { @@ -164,4 +186,51 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi $lastAutomaticTipWrittenDate | Should -Be $today } } + + Describe 'Calling TestIfUnseenTipsExist' { + BeforeEach { + # Use a temp configuration data directory instead of reading/overwriting the current user's configuration. + Mock -CommandName Get-TiPSDataDirectoryPath -MockWith { + [string] $directoryPath = "$TestDrive/tiPS" # Use $TestDrive variable so .NET methods can resolve the path. + if (-not (Test-Path -Path $directoryPath -PathType Container)) + { + New-Item -Path $directoryPath -ItemType Directory -Force > $null + } + return $directoryPath + } + } + + It 'Should return true when no tips have been shown yet' { + # Ensure the file is empty + ClearTipIdsAlreadyShown + + $result = TestIfUnseenTipsExist + + $result | Should -Be $true + } + + It 'Should return true when some tips have been shown but not all' { + # Get all tips and mark only one as shown + [hashtable] $allTips = ReadAllPowerShellTipsFromJsonFile + [string] $firstTipId = $allTips.Keys | Select-Object -First 1 + AppendTipIdToTipIdsAlreadyShown -TipId $firstTipId + + $result = TestIfUnseenTipsExist + + $result | Should -Be $true + } + + It 'Should return false when all tips have been shown' { + # Mark all tips as shown + [hashtable] $allTips = ReadAllPowerShellTipsFromJsonFile + foreach ($tipId in $allTips.Keys) + { + AppendTipIdToTipIdsAlreadyShown -TipId $tipId + } + + $result = TestIfUnseenTipsExist + + $result | Should -Be $false + } + } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index b7005a2..61a0c28 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -28,6 +28,7 @@ function WriteAutomaticPowerShellTipIfNeeded ([tiPS.WritePowerShellTipCadence]::Weekly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 7; break } ([tiPS.WritePowerShellTipCadence]::Biweekly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 14; break } ([tiPS.WritePowerShellTipCadence]::Monthly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 30; break } + ([tiPS.WritePowerShellTipCadence]::NewTipsOnly) { $shouldShowTip = TestIfUnseenTipsExist; break } } if ($shouldShowTip) @@ -137,3 +138,31 @@ function GetLastAutomaticTipWrittenDateFilePath [string] $lastAutomaticTipWrittenDateFilePath = Join-Path -Path $appDataDirectoryPath -ChildPath 'LastAutomaticTipWrittenDate.txt' return $lastAutomaticTipWrittenDateFilePath } + +function TestIfUnseenTipsExist +{ + [CmdletBinding()] + [OutputType([bool])] + Param() + + [hashtable] $allTips = ReadAllPowerShellTipsFromJsonFile + [string[]] $tipIdsAlreadyShown = ReadTipIdsAlreadyShownOrDefault + + # If no tips have been shown yet, there are definitely unseen tips + if ($tipIdsAlreadyShown.Count -eq 0) + { + return $true + } + + # Check if there are any tips that haven't been shown yet + foreach ($tipId in $allTips.Keys) + { + if ($tipId -notin $tipIdsAlreadyShown) + { + return $true + } + } + + # All tips have been shown + return $false +} diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 438cc58..2407df7 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -22,7 +22,8 @@ function Set-TiPSConfiguration .PARAMETER AutomaticallyWritePowerShellTip Whether to automatically write a PowerShell tip at session startup. - Valid values are Never, EverySession, Daily, Weekly, Biweekly, and Monthly. Default is Never. + Valid values are Never, EverySession, Daily, Weekly, Biweekly, Monthly, and NewTipsOnly. Default is Never. + NewTipsOnly will only show a tip if there are tips that have not been shown yet. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. From 081748951b4bd43b87a0eb825d34aa6fa9c037b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 23:30:28 +0000 Subject: [PATCH 03/11] Refactor to use WritePowerShellTipOptions enum instead of NewTipsOnly cadence Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- .../tiPSClasses/Configuration.cs | 11 ++++++-- ...maticWritePowerShellTipFunctions.Tests.ps1 | 8 +++--- .../AutomaticWritePowerShellTipFunctions.ps1 | 7 +++++- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 25 +++++++++++++++++-- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index a94f512..fec569d 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -16,8 +16,7 @@ public enum WritePowerShellTipCadence Daily = 2, Weekly = 3, Biweekly = 4, - Monthly = 5, - NewTipsOnly = 6 + Monthly = 5 } public enum TipRetrievalOrder @@ -27,17 +26,25 @@ public enum TipRetrievalOrder Random = 2 } + public enum WritePowerShellTipOptions + { + CycleThroughAllTips = 0, + UnseenTipsOnly = 1 + } + public class Configuration { public ModuleAutoUpdateCadence AutoUpdateCadence { get; set; } public WritePowerShellTipCadence AutoWritePowerShellTipCadence { get; set; } public TipRetrievalOrder TipRetrievalOrder { get; set; } + public WritePowerShellTipOptions AutoWritePowerShellTipOptions { get; set; } public Configuration() { AutoUpdateCadence = ModuleAutoUpdateCadence.Never; AutoWritePowerShellTipCadence = WritePowerShellTipCadence.Never; TipRetrievalOrder = TipRetrievalOrder.NewestFirst; + AutoWritePowerShellTipOptions = WritePowerShellTipOptions.CycleThroughAllTips; } } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index c88c60e..3bf44be 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,10 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the WritePowerShellTipCadence is NewTipsOnly' { + Context 'When the AutoWritePowerShellTipOptions is UnseenTipsOnly' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() - $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::NewTipsOnly + $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession + $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -155,7 +156,8 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() - $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::NewTipsOnly + $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession + $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 61a0c28..3b5620f 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -28,7 +28,12 @@ function WriteAutomaticPowerShellTipIfNeeded ([tiPS.WritePowerShellTipCadence]::Weekly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 7; break } ([tiPS.WritePowerShellTipCadence]::Biweekly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 14; break } ([tiPS.WritePowerShellTipCadence]::Monthly) { $shouldShowTip = $daysSinceLastAutomaticTipWritten -ge 30; break } - ([tiPS.WritePowerShellTipCadence]::NewTipsOnly) { $shouldShowTip = TestIfUnseenTipsExist; break } + } + + # If the cadence says we should show a tip, check if we should only show unseen tips + if ($shouldShowTip -and $Config.AutoWritePowerShellTipOptions -eq [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly) + { + $shouldShowTip = TestIfUnseenTipsExist } if ($shouldShowTip) diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 2407df7..eba4e74 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -22,8 +22,12 @@ function Set-TiPSConfiguration .PARAMETER AutomaticallyWritePowerShellTip Whether to automatically write a PowerShell tip at session startup. - Valid values are Never, EverySession, Daily, Weekly, Biweekly, Monthly, and NewTipsOnly. Default is Never. - NewTipsOnly will only show a tip if there are tips that have not been shown yet. + Valid values are Never, EverySession, Daily, Weekly, Biweekly, and Monthly. Default is Never. + + .PARAMETER AutomaticallyWritePowerShellTipOption + Controls how tips are selected when automatically showing tips. + Valid values are CycleThroughAllTips (default) and UnseenTipsOnly. + UnseenTipsOnly will only show tips that have not been shown yet. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -61,6 +65,11 @@ function Set-TiPSConfiguration Set-TiPSConfiguration -TipRetrievalOrder Random Set the tiPS configuration to retrieve PowerShell tips in random order. + + .EXAMPLE + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption UnseenTipsOnly + + Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'PartialConfiguration')] [OutputType([void])] @@ -76,6 +85,9 @@ function Set-TiPSConfiguration [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, + [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] + [tiPS.WritePowerShellTipOptions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipOptions]::CycleThroughAllTips, + [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] [tiPS.TipRetrievalOrder] $TipRetrievalOrder = [tiPS.TipRetrievalOrder]::NewestFirst @@ -119,6 +131,15 @@ function Set-TiPSConfiguration } } + # If the AutomaticallyWritePowerShellTipOption parameter is passed in, set it. + if ($PSBoundParameters.ContainsKey('AutomaticallyWritePowerShellTipOption')) + { + if ($PSCmdlet.ShouldProcess('tiPS configuration AutoWritePowerShellTipOptions property', 'Set')) + { + $script:TiPSConfiguration.AutoWritePowerShellTipOptions = $AutomaticallyWritePowerShellTipOption + } + } + Write-Debug "Saving the tiPS configuration to the configuration file." WriteConfigurationToFile -Config $script:TiPSConfiguration From 12ea78ec7481fb6834c931cd959dc916478250d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 00:25:27 +0000 Subject: [PATCH 04/11] Rename enum values: CycleThroughAllTips to CycleThroughTips, UnseenTipsOnly to OnlyWriteUnseenTips Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- src/CSharpClasses/tiPSClasses/Configuration.cs | 6 +++--- .../AutomaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index fec569d..fb999b5 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -28,8 +28,8 @@ public enum TipRetrievalOrder public enum WritePowerShellTipOptions { - CycleThroughAllTips = 0, - UnseenTipsOnly = 1 + CycleThroughTips = 0, + OnlyWriteUnseenTips = 1 } public class Configuration @@ -44,7 +44,7 @@ public Configuration() AutoUpdateCadence = ModuleAutoUpdateCadence.Never; AutoWritePowerShellTipCadence = WritePowerShellTipCadence.Never; TipRetrievalOrder = TipRetrievalOrder.NewestFirst; - AutoWritePowerShellTipOptions = WritePowerShellTipOptions.CycleThroughAllTips; + AutoWritePowerShellTipOptions = WritePowerShellTipOptions.CycleThroughTips; } } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 3bf44be..2ee8bb1 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the AutoWritePowerShellTipOptions is UnseenTipsOnly' { + Context 'When the AutoWritePowerShellTipOptions is OnlyWriteUnseenTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly + $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly + $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 3b5620f..fd34a94 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.AutoWritePowerShellTipOptions -eq [tiPS.WritePowerShellTipOptions]::UnseenTipsOnly) + if ($shouldShowTip -and $Config.AutoWritePowerShellTipOptions -eq [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index eba4e74..67946e5 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -26,8 +26,8 @@ function Set-TiPSConfiguration .PARAMETER AutomaticallyWritePowerShellTipOption Controls how tips are selected when automatically showing tips. - Valid values are CycleThroughAllTips (default) and UnseenTipsOnly. - UnseenTipsOnly will only show tips that have not been shown yet. + Valid values are CycleThroughTips (default) and OnlyWriteUnseenTips. + OnlyWriteUnseenTips will only show tips that have not been shown yet. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption UnseenTipsOnly + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnseenTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> @@ -86,7 +86,7 @@ function Set-TiPSConfiguration [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] - [tiPS.WritePowerShellTipOptions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipOptions]::CycleThroughAllTips, + [tiPS.WritePowerShellTipOptions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipOptions]::CycleThroughTips, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] From 03f9323cc01ca062e9fe6ddde318144358764d60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 00:28:45 +0000 Subject: [PATCH 05/11] Add ReadMe example for OnlyWriteUnseenTips option Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- ReadMe.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ReadMe.md b/ReadMe.md index 2786593..9c073c3 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -144,6 +144,20 @@ Possible values for the `-AutomaticallyWritePowerShellTip` parameter are `Never` Tips will only be automatically shown in interactive PowerShell sessions. This prevents them from appearing unexpectedly when running scripts or other automated processes. +#### Show only unseen tips + +By default, tips will cycle through all available tips. +If you prefer to only see tips that you haven't seen before, you can configure tiPS to only show unseen tips by running: + +```powershell +Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnseenTips +``` + +Possible values for the `-AutomaticallyWritePowerShellTipOption` parameter are `CycleThroughTips` (default) and `OnlyWriteUnseenTips`. + +When `OnlyWriteUnseenTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. +Once all tips have been shown, no more tips will be automatically displayed until new tips are added to the module (typically by updating the module). + ### ⬆️ Automatic updates New tips are obtained by updating the tiPS module. From 7411dbfbcfa46c1956ca0d6e5ac9b14d99dde1a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 00:47:37 +0000 Subject: [PATCH 06/11] Rename WritePowerShellTipOptions to WritePowerShellTipConditions and AutoWritePowerShellTipOptions to WritePowerShellTipCondition Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- src/CSharpClasses/tiPSClasses/Configuration.cs | 6 +++--- .../Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index fb999b5..9b7e17c 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -26,7 +26,7 @@ public enum TipRetrievalOrder Random = 2 } - public enum WritePowerShellTipOptions + public enum WritePowerShellTipConditions { CycleThroughTips = 0, OnlyWriteUnseenTips = 1 @@ -37,14 +37,14 @@ public class Configuration public ModuleAutoUpdateCadence AutoUpdateCadence { get; set; } public WritePowerShellTipCadence AutoWritePowerShellTipCadence { get; set; } public TipRetrievalOrder TipRetrievalOrder { get; set; } - public WritePowerShellTipOptions AutoWritePowerShellTipOptions { get; set; } + public WritePowerShellTipConditions WritePowerShellTipCondition { get; set; } public Configuration() { AutoUpdateCadence = ModuleAutoUpdateCadence.Never; AutoWritePowerShellTipCadence = WritePowerShellTipCadence.Never; TipRetrievalOrder = TipRetrievalOrder.NewestFirst; - AutoWritePowerShellTipOptions = WritePowerShellTipOptions.CycleThroughTips; + WritePowerShellTipCondition = WritePowerShellTipConditions.CycleThroughTips; } } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 2ee8bb1..8500b68 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the AutoWritePowerShellTipOptions is OnlyWriteUnseenTips' { + Context 'When the WritePowerShellTipCondition is OnlyWriteUnseenTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips + $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.AutoWritePowerShellTipOptions = [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips + $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index fd34a94..18b50ae 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.AutoWritePowerShellTipOptions -eq [tiPS.WritePowerShellTipOptions]::OnlyWriteUnseenTips) + if ($shouldShowTip -and $Config.WritePowerShellTipCondition -eq [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 67946e5..743b8d9 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -86,7 +86,7 @@ function Set-TiPSConfiguration [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] - [tiPS.WritePowerShellTipOptions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipOptions]::CycleThroughTips, + [tiPS.WritePowerShellTipConditions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipConditions]::CycleThroughTips, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] @@ -134,9 +134,9 @@ function Set-TiPSConfiguration # If the AutomaticallyWritePowerShellTipOption parameter is passed in, set it. if ($PSBoundParameters.ContainsKey('AutomaticallyWritePowerShellTipOption')) { - if ($PSCmdlet.ShouldProcess('tiPS configuration AutoWritePowerShellTipOptions property', 'Set')) + if ($PSCmdlet.ShouldProcess('tiPS configuration WritePowerShellTipCondition property', 'Set')) { - $script:TiPSConfiguration.AutoWritePowerShellTipOptions = $AutomaticallyWritePowerShellTipOption + $script:TiPSConfiguration.WritePowerShellTipCondition = $AutomaticallyWritePowerShellTipOption } } From 145851eac785af505a569b13c49206a4744bca69 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Mon, 27 Oct 2025 18:53:40 -0600 Subject: [PATCH 07/11] Rename OnlyWriteUnseenTips to OnlyWriteUnshownTips --- ReadMe.md | 12 ++++++------ src/CSharpClasses/tiPSClasses/Configuration.cs | 2 +- .../AutomaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- .../Private/AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 9c073c3..87aa4ce 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -144,18 +144,18 @@ Possible values for the `-AutomaticallyWritePowerShellTip` parameter are `Never` Tips will only be automatically shown in interactive PowerShell sessions. This prevents them from appearing unexpectedly when running scripts or other automated processes. -#### Show only unseen tips +#### Write only unshown tips -By default, tips will cycle through all available tips. -If you prefer to only see tips that you haven't seen before, you can configure tiPS to only show unseen tips by running: +By default, tiPS will cycle through all available tips. +If you prefer to only see tips that you haven't shown before, you can configure tiPS to only show unshown tips by running: ```powershell -Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnseenTips +Set-TiPSConfiguration -AutomaticallyWritePowerShellTipOption OnlyWriteUnshownTips ``` -Possible values for the `-AutomaticallyWritePowerShellTipOption` parameter are `CycleThroughTips` (default) and `OnlyWriteUnseenTips`. +Possible values for the `-AutomaticallyWritePowerShellTipOption` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. -When `OnlyWriteUnseenTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. +When `OnlyWriteUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. Once all tips have been shown, no more tips will be automatically displayed until new tips are added to the module (typically by updating the module). ### ⬆️ Automatic updates diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index 9b7e17c..ed11b65 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -29,7 +29,7 @@ public enum TipRetrievalOrder public enum WritePowerShellTipConditions { CycleThroughTips = 0, - OnlyWriteUnseenTips = 1 + OnlyWriteUnshownTips = 1 } public class Configuration diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 8500b68..6aa5cf5 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the WritePowerShellTipCondition is OnlyWriteUnseenTips' { + Context 'When the WritePowerShellTipCondition is OnlyWriteUnshownTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips + $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips + $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 18b50ae..8bfee44 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.WritePowerShellTipCondition -eq [tiPS.WritePowerShellTipConditions]::OnlyWriteUnseenTips) + if ($shouldShowTip -and $Config.WritePowerShellTipCondition -eq [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 743b8d9..39e04fe 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -26,8 +26,8 @@ function Set-TiPSConfiguration .PARAMETER AutomaticallyWritePowerShellTipOption Controls how tips are selected when automatically showing tips. - Valid values are CycleThroughTips (default) and OnlyWriteUnseenTips. - OnlyWriteUnseenTips will only show tips that have not been shown yet. + Valid values are CycleThroughTips (default) and OnlyWriteUnshownTips. + OnlyWriteUnshownTips will only show tips that have not been shown yet. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnseenTips + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnshownTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> From 432df068eea9e9b0d7ff1f87a1c529d822aee81e Mon Sep 17 00:00:00 2001 From: deadlydog Date: Mon, 27 Oct 2025 19:02:16 -0600 Subject: [PATCH 08/11] Rename AutomaticallyWritePowerShellTipOption to WritePowerShellTipCondition --- ReadMe.md | 12 ++++++------ src/tiPS/Public/Set-TiPSConfiguration.ps1 | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 87aa4ce..ce4de71 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -144,19 +144,19 @@ Possible values for the `-AutomaticallyWritePowerShellTip` parameter are `Never` Tips will only be automatically shown in interactive PowerShell sessions. This prevents them from appearing unexpectedly when running scripts or other automated processes. -#### Write only unshown tips +#### Do not show the same tips twice -By default, tiPS will cycle through all available tips. -If you prefer to only see tips that you haven't shown before, you can configure tiPS to only show unshown tips by running: +By default, tiPS will cycle through all available tips, so once all tips have been shown it will restart and display them again. +If you prefer to only see tips that haven't been shown before, you can configure tiPS to only show unshown tips by running: ```powershell -Set-TiPSConfiguration -AutomaticallyWritePowerShellTipOption OnlyWriteUnshownTips +Set-TiPSConfiguration -WritePowerShellTipCondition OnlyWriteUnshownTips ``` -Possible values for the `-AutomaticallyWritePowerShellTipOption` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. +Possible values for the `-WritePowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. When `OnlyWriteUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. -Once all tips have been shown, no more tips will be automatically displayed until new tips are added to the module (typically by updating the module). +Once all tips have been shown, no more tips will be displayed until new tips are added (by updating the module). ### ⬆️ Automatic updates diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 39e04fe..cc5b694 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -24,10 +24,10 @@ function Set-TiPSConfiguration Whether to automatically write a PowerShell tip at session startup. Valid values are Never, EverySession, Daily, Weekly, Biweekly, and Monthly. Default is Never. - .PARAMETER AutomaticallyWritePowerShellTipOption + .PARAMETER WritePowerShellTipCondition Controls how tips are selected when automatically showing tips. Valid values are CycleThroughTips (default) and OnlyWriteUnshownTips. - OnlyWriteUnshownTips will only show tips that have not been shown yet. + OnlyWriteUnshownTips will only show tips that have not been shown before. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AutomaticallyWritePowerShellTipOption OnlyWriteUnshownTips + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -WritePowerShellTipCondition OnlyWriteUnshownTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> @@ -86,7 +86,7 @@ function Set-TiPSConfiguration [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] - [tiPS.WritePowerShellTipConditions] $AutomaticallyWritePowerShellTipOption = [tiPS.WritePowerShellTipConditions]::CycleThroughTips, + [tiPS.WritePowerShellTipConditions] $WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::CycleThroughTips, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] @@ -131,12 +131,12 @@ function Set-TiPSConfiguration } } - # If the AutomaticallyWritePowerShellTipOption parameter is passed in, set it. - if ($PSBoundParameters.ContainsKey('AutomaticallyWritePowerShellTipOption')) + # If the WritePowerShellTipCondition parameter is passed in, set it. + if ($PSBoundParameters.ContainsKey('WritePowerShellTipCondition')) { if ($PSCmdlet.ShouldProcess('tiPS configuration WritePowerShellTipCondition property', 'Set')) { - $script:TiPSConfiguration.WritePowerShellTipCondition = $AutomaticallyWritePowerShellTipOption + $script:TiPSConfiguration.WritePowerShellTipCondition = $WritePowerShellTipCondition } } From daa49b7bdb37e8815639f5175ebab15d2c4f4761 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 01:33:02 +0000 Subject: [PATCH 09/11] Rename WritePowerShellTipConditions to GetPowerShellTipConditions and WritePowerShellTipCondition to GetPowerShellTipCondition Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- ReadMe.md | 4 ++-- src/CSharpClasses/tiPSClasses/Configuration.cs | 6 +++--- .../AutomaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- .../AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 14 +++++++------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index ce4de71..dda3cdf 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -150,10 +150,10 @@ By default, tiPS will cycle through all available tips, so once all tips have be If you prefer to only see tips that haven't been shown before, you can configure tiPS to only show unshown tips by running: ```powershell -Set-TiPSConfiguration -WritePowerShellTipCondition OnlyWriteUnshownTips +Set-TiPSConfiguration -GetPowerShellTipCondition OnlyWriteUnshownTips ``` -Possible values for the `-WritePowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. +Possible values for the `-GetPowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. When `OnlyWriteUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. Once all tips have been shown, no more tips will be displayed until new tips are added (by updating the module). diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index ed11b65..937ed00 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -26,7 +26,7 @@ public enum TipRetrievalOrder Random = 2 } - public enum WritePowerShellTipConditions + public enum GetPowerShellTipConditions { CycleThroughTips = 0, OnlyWriteUnshownTips = 1 @@ -37,14 +37,14 @@ public class Configuration public ModuleAutoUpdateCadence AutoUpdateCadence { get; set; } public WritePowerShellTipCadence AutoWritePowerShellTipCadence { get; set; } public TipRetrievalOrder TipRetrievalOrder { get; set; } - public WritePowerShellTipConditions WritePowerShellTipCondition { get; set; } + public GetPowerShellTipConditions GetPowerShellTipCondition { get; set; } public Configuration() { AutoUpdateCadence = ModuleAutoUpdateCadence.Never; AutoWritePowerShellTipCadence = WritePowerShellTipCadence.Never; TipRetrievalOrder = TipRetrievalOrder.NewestFirst; - WritePowerShellTipCondition = WritePowerShellTipConditions.CycleThroughTips; + GetPowerShellTipCondition = GetPowerShellTipConditions.CycleThroughTips; } } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 6aa5cf5..bc50d99 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the WritePowerShellTipCondition is OnlyWriteUnshownTips' { + Context 'When the GetPowerShellTipCondition is OnlyWriteUnshownTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips + $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips + $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 8bfee44..1f43ea6 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.WritePowerShellTipCondition -eq [tiPS.WritePowerShellTipConditions]::OnlyWriteUnshownTips) + if ($shouldShowTip -and $Config.GetPowerShellTipCondition -eq [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index cc5b694..3faa14a 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -24,7 +24,7 @@ function Set-TiPSConfiguration Whether to automatically write a PowerShell tip at session startup. Valid values are Never, EverySession, Daily, Weekly, Biweekly, and Monthly. Default is Never. - .PARAMETER WritePowerShellTipCondition + .PARAMETER GetPowerShellTipCondition Controls how tips are selected when automatically showing tips. Valid values are CycleThroughTips (default) and OnlyWriteUnshownTips. OnlyWriteUnshownTips will only show tips that have not been shown before. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -WritePowerShellTipCondition OnlyWriteUnshownTips + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -GetPowerShellTipCondition OnlyWriteUnshownTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> @@ -86,7 +86,7 @@ function Set-TiPSConfiguration [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] - [tiPS.WritePowerShellTipConditions] $WritePowerShellTipCondition = [tiPS.WritePowerShellTipConditions]::CycleThroughTips, + [tiPS.GetPowerShellTipConditions] $GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::CycleThroughTips, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] @@ -131,12 +131,12 @@ function Set-TiPSConfiguration } } - # If the WritePowerShellTipCondition parameter is passed in, set it. - if ($PSBoundParameters.ContainsKey('WritePowerShellTipCondition')) + # If the GetPowerShellTipCondition parameter is passed in, set it. + if ($PSBoundParameters.ContainsKey('GetPowerShellTipCondition')) { - if ($PSCmdlet.ShouldProcess('tiPS configuration WritePowerShellTipCondition property', 'Set')) + if ($PSCmdlet.ShouldProcess('tiPS configuration GetPowerShellTipCondition property', 'Set')) { - $script:TiPSConfiguration.WritePowerShellTipCondition = $WritePowerShellTipCondition + $script:TiPSConfiguration.GetPowerShellTipCondition = $GetPowerShellTipCondition } } From 61fae99101b494cb21c98ea000140df1052fdfe4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 01:56:07 +0000 Subject: [PATCH 10/11] Rename OnlyWriteUnshownTips to OnlyGetUnshownTips Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- ReadMe.md | 6 +++--- src/CSharpClasses/tiPSClasses/Configuration.cs | 2 +- .../Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index dda3cdf..9cde9f1 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -150,12 +150,12 @@ By default, tiPS will cycle through all available tips, so once all tips have be If you prefer to only see tips that haven't been shown before, you can configure tiPS to only show unshown tips by running: ```powershell -Set-TiPSConfiguration -GetPowerShellTipCondition OnlyWriteUnshownTips +Set-TiPSConfiguration -GetPowerShellTipCondition OnlyGetUnshownTips ``` -Possible values for the `-GetPowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyWriteUnshownTips`. +Possible values for the `-GetPowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyGetUnshownTips`. -When `OnlyWriteUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. +When `OnlyGetUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. Once all tips have been shown, no more tips will be displayed until new tips are added (by updating the module). ### ⬆️ Automatic updates diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index 937ed00..565c357 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -29,7 +29,7 @@ public enum TipRetrievalOrder public enum GetPowerShellTipConditions { CycleThroughTips = 0, - OnlyWriteUnshownTips = 1 + OnlyGetUnshownTips = 1 } public class Configuration diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index bc50d99..68bd198 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the GetPowerShellTipCondition is OnlyWriteUnshownTips' { + Context 'When the GetPowerShellTipCondition is OnlyGetUnshownTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips + $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips + $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 1f43ea6..9944a48 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.GetPowerShellTipCondition -eq [tiPS.GetPowerShellTipConditions]::OnlyWriteUnshownTips) + if ($shouldShowTip -and $Config.GetPowerShellTipCondition -eq [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index 3faa14a..ae02a8c 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -26,8 +26,8 @@ function Set-TiPSConfiguration .PARAMETER GetPowerShellTipCondition Controls how tips are selected when automatically showing tips. - Valid values are CycleThroughTips (default) and OnlyWriteUnshownTips. - OnlyWriteUnshownTips will only show tips that have not been shown before. + Valid values are CycleThroughTips (default) and OnlyGetUnshownTips. + OnlyGetUnshownTips will only show tips that have not been shown before. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -GetPowerShellTipCondition OnlyWriteUnshownTips + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -GetPowerShellTipCondition OnlyGetUnshownTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> From 73e2c889a8ea7a4df5fba228d64b83d95b4c4745 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 02:31:04 +0000 Subject: [PATCH 11/11] Rename enum and values: GetPowerShellTipConditions to AllTipsShownBehaviours, CycleThroughTips to ClearShownTipsList, OnlyGetUnshownTips to DoNotShowTips, GetPowerShellTipCondition to AllTipsShownBehaviour Co-authored-by: deadlydog <1187140+deadlydog@users.noreply.github.com> --- ReadMe.md | 6 +++--- src/CSharpClasses/tiPSClasses/Configuration.cs | 10 +++++----- ...omaticWritePowerShellTipFunctions.Tests.ps1 | 6 +++--- .../AutomaticWritePowerShellTipFunctions.ps1 | 2 +- src/tiPS/Public/Set-TiPSConfiguration.ps1 | 18 +++++++++--------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 9cde9f1..1cf0763 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -150,12 +150,12 @@ By default, tiPS will cycle through all available tips, so once all tips have be If you prefer to only see tips that haven't been shown before, you can configure tiPS to only show unshown tips by running: ```powershell -Set-TiPSConfiguration -GetPowerShellTipCondition OnlyGetUnshownTips +Set-TiPSConfiguration -AllTipsShownBehaviour DoNotShowTips ``` -Possible values for the `-GetPowerShellTipCondition` parameter are `CycleThroughTips` (default) and `OnlyGetUnshownTips`. +Possible values for the `-AllTipsShownBehaviour` parameter are `ClearShownTipsList` (default) and `DoNotShowTips`. -When `OnlyGetUnshownTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. +When `DoNotShowTips` is used, tiPS will only automatically display a tip if there are tips that have not been shown yet. Once all tips have been shown, no more tips will be displayed until new tips are added (by updating the module). ### ⬆️ Automatic updates diff --git a/src/CSharpClasses/tiPSClasses/Configuration.cs b/src/CSharpClasses/tiPSClasses/Configuration.cs index 565c357..1841b15 100644 --- a/src/CSharpClasses/tiPSClasses/Configuration.cs +++ b/src/CSharpClasses/tiPSClasses/Configuration.cs @@ -26,10 +26,10 @@ public enum TipRetrievalOrder Random = 2 } - public enum GetPowerShellTipConditions + public enum AllTipsShownBehaviours { - CycleThroughTips = 0, - OnlyGetUnshownTips = 1 + ClearShownTipsList = 0, + DoNotShowTips = 1 } public class Configuration @@ -37,14 +37,14 @@ public class Configuration public ModuleAutoUpdateCadence AutoUpdateCadence { get; set; } public WritePowerShellTipCadence AutoWritePowerShellTipCadence { get; set; } public TipRetrievalOrder TipRetrievalOrder { get; set; } - public GetPowerShellTipConditions GetPowerShellTipCondition { get; set; } + public AllTipsShownBehaviours AllTipsShownBehaviour { get; set; } public Configuration() { AutoUpdateCadence = ModuleAutoUpdateCadence.Never; AutoWritePowerShellTipCadence = WritePowerShellTipCadence.Never; TipRetrievalOrder = TipRetrievalOrder.NewestFirst; - GetPowerShellTipCondition = GetPowerShellTipConditions.CycleThroughTips; + AllTipsShownBehaviour = AllTipsShownBehaviours.ClearShownTipsList; } } } diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 index 68bd198..fb4bea5 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.Tests.ps1 @@ -142,11 +142,11 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi } } - Context 'When the GetPowerShellTipCondition is OnlyGetUnshownTips' { + Context 'When the AllTipsShownBehaviour is DoNotShowTips' { It 'Should show a tip when there are unseen tips' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips + $config.AllTipsShownBehaviour = [tiPS.AllTipsShownBehaviours]::DoNotShowTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $true } WriteAutomaticPowerShellTipIfNeeded -Config $config @@ -157,7 +157,7 @@ InModuleScope -ModuleName tiPS { # Must use InModuleScope to call private functi It 'Should not show a tip when all tips have been shown' { $config = [tiPS.Configuration]::new() $config.AutoWritePowerShellTipCadence = [tiPS.WritePowerShellTipCadence]::EverySession - $config.GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips + $config.AllTipsShownBehaviour = [tiPS.AllTipsShownBehaviours]::DoNotShowTips Mock -CommandName TestIfUnseenTipsExist -MockWith { return $false } WriteAutomaticPowerShellTipIfNeeded -Config $config diff --git a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 index 9944a48..1c52430 100644 --- a/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 +++ b/src/tiPS/Private/AutomaticWritePowerShellTipFunctions.ps1 @@ -31,7 +31,7 @@ function WriteAutomaticPowerShellTipIfNeeded } # If the cadence says we should show a tip, check if we should only show unseen tips - if ($shouldShowTip -and $Config.GetPowerShellTipCondition -eq [tiPS.GetPowerShellTipConditions]::OnlyGetUnshownTips) + if ($shouldShowTip -and $Config.AllTipsShownBehaviour -eq [tiPS.AllTipsShownBehaviours]::DoNotShowTips) { $shouldShowTip = TestIfUnseenTipsExist } diff --git a/src/tiPS/Public/Set-TiPSConfiguration.ps1 b/src/tiPS/Public/Set-TiPSConfiguration.ps1 index ae02a8c..4cde6c4 100644 --- a/src/tiPS/Public/Set-TiPSConfiguration.ps1 +++ b/src/tiPS/Public/Set-TiPSConfiguration.ps1 @@ -24,10 +24,10 @@ function Set-TiPSConfiguration Whether to automatically write a PowerShell tip at session startup. Valid values are Never, EverySession, Daily, Weekly, Biweekly, and Monthly. Default is Never. - .PARAMETER GetPowerShellTipCondition + .PARAMETER AllTipsShownBehaviour Controls how tips are selected when automatically showing tips. - Valid values are CycleThroughTips (default) and OnlyGetUnshownTips. - OnlyGetUnshownTips will only show tips that have not been shown before. + Valid values are ClearShownTipsList (default) and DoNotShowTips. + DoNotShowTips will only show tips that have not been shown before. .PARAMETER TipRetrievalOrder The order in which to retrieve PowerShell tips. @@ -67,7 +67,7 @@ function Set-TiPSConfiguration Set the tiPS configuration to retrieve PowerShell tips in random order. .EXAMPLE - Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -GetPowerShellTipCondition OnlyGetUnshownTips + Set-TiPSConfiguration -AutomaticallyWritePowerShellTip Daily -AllTipsShownBehaviour DoNotShowTips Set the tiPS configuration to automatically write a PowerShell tip every day, but only if there are tips that have not been shown yet. #> @@ -86,7 +86,7 @@ function Set-TiPSConfiguration [tiPS.WritePowerShellTipCadence] $AutomaticallyWritePowerShellTip = [tiPS.WritePowerShellTipCadence]::Never, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] - [tiPS.GetPowerShellTipConditions] $GetPowerShellTipCondition = [tiPS.GetPowerShellTipConditions]::CycleThroughTips, + [tiPS.AllTipsShownBehaviours] $AllTipsShownBehaviour = [tiPS.AllTipsShownBehaviours]::ClearShownTipsList, [Parameter(Mandatory = $false, ParameterSetName = 'PartialConfiguration', ValueFromPipelineByPropertyName = $true)] [Alias('TipOrder')] @@ -131,12 +131,12 @@ function Set-TiPSConfiguration } } - # If the GetPowerShellTipCondition parameter is passed in, set it. - if ($PSBoundParameters.ContainsKey('GetPowerShellTipCondition')) + # If the AllTipsShownBehaviour parameter is passed in, set it. + if ($PSBoundParameters.ContainsKey('AllTipsShownBehaviour')) { - if ($PSCmdlet.ShouldProcess('tiPS configuration GetPowerShellTipCondition property', 'Set')) + if ($PSCmdlet.ShouldProcess('tiPS configuration AllTipsShownBehaviour property', 'Set')) { - $script:TiPSConfiguration.GetPowerShellTipCondition = $GetPowerShellTipCondition + $script:TiPSConfiguration.AllTipsShownBehaviour = $AllTipsShownBehaviour } }