`New-SampleModule`: document `-Features` auto-switch in help and consider `Write-Warning`
- Dominant language
- PowerShell
- Stars
- 243
- Forks
- 46
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 1
Description
**Problem description**
PR #560 landed with a `Write-Verbose` auto-switch in `Sampler/Public/New-SampleModule.ps1`:
```powershell
if ($PSBoundParameters.ContainsKey('Features') -and -not $PSBoundParameters.ContainsKey('ModuleType'))
{
Write-Verbose -Message ('Features parameter is only effective when ModuleType is CustomModule. Switching ModuleType to CustomModule to honor the selected features.')
$ModuleType = 'CustomModule'
}
```
Two remaining gaps from the original review:
1. The behavior is not discoverable from `Get-Help New-SampleModule -Parameter Features`. The `.PARAMETER Features` block lists valid values but does not mention that supplying `-Features` without `-ModuleType` defaults `-ModuleType` to `CustomModule`.
2. `Write-Verbose` is silent unless the caller passes `-Verbose`, so a user who does not ask for verbose output still gets a silently coerced `ModuleType`. `Write-Warning` is the usual pattern for "we changed your input" paths.
Gael indicated in #560 that the longer-term fix is to rework the Plaster `Condition` logic so `-Features` works with any template, at which point the auto-switch can go away entirely. This issue tracks the small interim improvements in case that larger rework does not land before the next full release.
**Verbose logs**
N/A
**How to reproduce**
1. `Get-Help New-SampleModule -Parameter Features` — note that the auto-switch is not mentioned.
2. `New-SampleModule -DestinationPath . -ModuleName X -ModuleDescription Y -CustomRepo PSGallery -Features git,UnitTests` (without `-Verbose`) — note that `ModuleType` is silently coerced to `CustomModule` with no console output.
**Expected behavior**
- `.PARAMETER Features` help explicitly documents the auto-switch.
- The user gets some form of visible signal when the auto-switch fires, unless the "features-with-any-template" rework removes the need for it.
**Current behavior**
Behavior is documented only in the wiki tip box and is signalled only via `Write-Verbose`.
**Suggested solution**
- Add a sentence to `.PARAMETER Features` in `Sampler/Public/New-SampleModule.ps1`.
- Consider replacing `Write-Verbose` with `Write-Warning`, or remove the auto-switch entirely as part of the template-condition rework.
**Operating system the target node is running**
N/A
**PowerShell version and build the target node is running**
N/A
**Module version used**
Sampler `Unreleased` / post-#560.
Contributor guide
Research direction
Start in Sampler/Public/New-SampleModule.ps1 by reading the .PARAMETER Features help block and the conditional that changes ModuleType. Reproduce the behavior with Get-Help and the New-SampleModule command shown in the issue. Done means the auto-switch is explained in help and users receive a visible signal, unless the template-condition rework removes that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100