Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Format-Checklist does not accept parameter input #29

Open
bstrautin opened this issue Sep 8, 2019 · 4 comments · May be fixed by #69
Open

Format-Checklist does not accept parameter input #29

bstrautin opened this issue Sep 8, 2019 · 4 comments · May be fixed by #69
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bstrautin
Copy link

Format-Checklist fails when passing a RequirementEvent[] object as a parameter. It should format the objects as it does when they are passed in from the pipeline.

Error:

Format-Checklist : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type
"System.DateTime"."
At line:25 char:1
+ Format-Checklist -RequirementEvent $output   # fails
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Format-Checklist], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Format-Checklist

Code to reproduce:

$mySystem = [collections.generic.list[int]]::new()

$requirements = @(
    @{
        Name     = "Resource 1"
        Describe = "Resource 1 is present in the system"
        Test     = { $mySystem -contains 1 }
        Set      = { $mySystem.Add(1) | Out-Null; Start-Sleep 1 }
    },
    @{
        Name     = "Resource 2"
        Describe = "Resource 2 is present in the system"
        Test     = { $mySystem -contains 2 }
        Set      = { $mySystem.Add(2) | Out-Null; Start-Sleep 1 }
    }
)

$output = $requirements | Invoke-Requirement

$output | Format-Table | Out-Host            # works
Format-Table -InputObject $output | Out-Host # works

$output | Format-Checklist | Out-Host        # works
Format-Checklist -RequirementEvent $output   # fails

@chriskuech
Copy link
Contributor

Seems like

  1. the parameter attribute should be changed from ValueFromPipeline to ValueFromPipelineByPropertyName
  2. the process block should wrap a foreach loop around the current process block content
  3. update the iterated value from $_ to $event or something similar

@chriskuech chriskuech added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Sep 8, 2019
@chriskuech
Copy link
Contributor

I should probably add that I'm not sure why anyone would do this. Format-Checklist is meant for real-time updating of the host. If you want non-realtime, you're probably better off using the other Format-* cmdlets that support stream redirection.

@bstrautin
Copy link
Author

Users' wants and developers' expectations are rarely in sync. :-)

@chriskuech
Copy link
Contributor

Well, my attempted solution seemed to stop the formatters from accepting pipeline input. Not sure if anyone has any ideas here...

@cdhunt cdhunt linked a pull request Oct 1, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants