Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "trickle" parsing #194

Open
DennisL68 opened this issue May 15, 2023 · 6 comments
Open

Implement "trickle" parsing #194

DennisL68 opened this issue May 15, 2023 · 6 comments
Labels
Issue-Answered Issue concerns addressed in conversation Issue-Enhancement New feature or request Issue-Triaged issue was read and triaged

Comments

@DennisL68
Copy link

Summary of the new feature / enhancement

As a user of a command that provides multiple outputs over time before finishing
I'd like to be able to start parsing the output before the complete command has ended
So that I can take action on certain statuses in the output

Proposed technical implementation details (optional)

I don't know how feasible this is though...

Start-Job {
  <command args>
} -Name <command arg>

while ($job.state -ne 'Completed') {
  $job = Get-Job -Name <command arg>
  $job | Receive-Job
  sleep -Milliseconds 400
}
@DennisL68 DennisL68 added the Issue-Enhancement New feature or request label May 15, 2023
@theJasonHelmick
Copy link
Collaborator

Hi @DennisL68 -- thank you. PowerShell returns each object as quickly as the command sends it to the output. When there is a filter, job or sort - The command performing the sort holds the objects from the output, until it can complete the sort, then returns all the objects in the correct sort order. In the case of background jobs, you can get the results before the job has completed with receive-job, but I gather this is not the result you're after. For more information on PowerShell jobs, see https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_jobs?view=powershell-7.3#getting-the-results-of-a-job

@theJasonHelmick theJasonHelmick added Issue-Triaged issue was read and triaged Issue-Answered Issue concerns addressed in conversation labels May 25, 2023
@DennisL68
Copy link
Author

Ok, what I'm having issues with in particular is psconfig.exe for SharePoint server.
It takes a very long time to execute, and outputs various outputs, errors and statuses along the way.

I would like to have the option to abort the run on the first error detected by my parser, instead of having to wait for the "final" result until the end.

@theJasonHelmick
Copy link
Collaborator

@DennisL68 -- after re-reading this - I would also suggest looking at the json property StreamOutput of the output handler. Set this to true and the output will stream to the handler. Here's an example: https://github.com/PowerShell/Crescendo/blob/master/Microsoft.PowerShell.Crescendo/Samples/ifconfig.crescendo.json

@DennisL68
Copy link
Author

Yes, but...

MS SharePoint psconfig.exe doesn't provide json output...

I'm using my own parser function.

@nlsdg
Copy link

nlsdg commented Aug 9, 2023

@DennisL68 If you look at the ifconfig example you'll see that it also doesn't provide json output by itself.
It uses the jc and ConvertTo-Json commands.
"Handler": "$input | jc --ifconfig | ConvertFrom-Json"

@DennisL68
Copy link
Author

What is jc?

Judging by the syntax it seems to be some kind of Linux command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Answered Issue concerns addressed in conversation Issue-Enhancement New feature or request Issue-Triaged issue was read and triaged
Projects
None yet
Development

No branches or pull requests

3 participants