-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature/enhancement
The concept is the ability to register a scriptblock for a specific native command to allow the scriptblock to parse the output and return objects. A format.ps1xml would be optionally registered as a parameter to get nice formatting.
The assumption is that in most cases, if the parser is registered then the default is to use it so that objects are returned even though the native command itself returns text. It might be ok to say if the command is last in the pipeline, it is ok to execute the parser. If the next command in the pipeline is native, then text is expected. If the next command is PowerShell, then execute the parser and pass objects down the pipeline.
There may still be a need to require text even when working with PowerShell in the pipeline, so need a way to specify that selectively.
Proposed technical implementation details (optional)
register-outputparser -nativecommand kubectl -scriptblock { param($stdout, $args) ... }$stdout as the first param would contain the text output, probably no streaming semantics
$args is the args passed to the native command as an array of strings
if the scriptblock determines it can't process the data it should just return $stdout back out