Skip to content

New-SampleModule: document -Features auto-switch in help and consider Write-Warning #567

@raandree

Description

@raandree

Problem description
PR #560 landed with a Write-Verbose auto-switch in Sampler/Public/New-SampleModule.ps1:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions