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

Support writing progress as JSON #614

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

anmenaga
Copy link
Collaborator

@anmenaga anmenaga commented Dec 12, 2024

PR Summary

Fix #592

  1. This adds writing json progress messages to STDERR stream if -f, --format argument to dsc.exe is json or pretty-json.
  2. Fixed a bug with Searching for adapted resources progress which previously was always showing 0.

The structure of json progress message is following. activity and percent_complete are expected to always have value; the rest of the fields are optional.
Same structure will be expected from resources when they will want to provide progress status to dsc (this support will be implemented soon).

pub struct DscProgressValue {
    pub activity:  String,
    pub status: String,
    pub percent_complete: u16,
    pub seconds_remaining: u64,
}

Dev notes:

  1. Added struct DscProgressBar which is wrapping both UI progress bar and json serialization;
  2. moved pub enum OutputFormat from dsc to dsc_lib and updated all references.

@anmenaga anmenaga marked this pull request as draft December 12, 2024 20:11
@anmenaga anmenaga marked this pull request as ready for review December 12, 2024 22:53
dsc/src/subcommand.rs Outdated Show resolved Hide resolved
$LASTEXITCODE | Should -Be 0
$lines = Get-Content $TestDrive/ErrorStream.txt
$ProgressMessagesFound = $False
foreach ($line in $lines) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of comparing text, since all output should be JSON, you should convert every line from json and check the object

$lines = Get-Content $TestDrive/ErrorStream.txt
$ProgressMessagesFound = $False
foreach ($line in $lines) {
if ($line.Contains("activity")) { # if line is a progress message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, use convertfrom-json

dsc_lib/src/configure/mod.rs Outdated Show resolved Hide resolved
dsc_lib/src/util.rs Outdated Show resolved Hide resolved
dsc_lib/src/util.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support writing progress as JSON
2 participants