-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
Conversation
} | ||
}; | ||
|
||
let mut configurator = match Configurator::new(&json_string) { | ||
let mut configurator = match Configurator::new(&json_string, output_format.as_ref()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having output_format
as a parameter to the constructor. Would prefer adding a set_output_format()
function instead. Alternatively since this is something used all over the place, maybe put into thread local storage and just retrieve from there instead of passing it around particularly since it shouldn't change during runtime.
$LASTEXITCODE | Should -Be 0 | ||
$lines = Get-Content $TestDrive/ErrorStream.txt | ||
$ProgressMessagesFound = $False | ||
foreach ($line in $lines) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
json: String, | ||
config: Configuration, | ||
pub context: Context, | ||
discovery: Discovery, | ||
statement_parser: Statement, | ||
progress_format: Option<&'a OutputFormat>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this as an Option, I think it should just be OutputFormat
and you have the constructor set a default. This should also remove the need for lifetime.
@@ -24,6 +37,88 @@ impl Default for DscSettingValue { | |||
} | |||
} | |||
|
|||
#[derive(Default, Debug, Clone, Serialize)] | |||
pub struct DscProgressValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the struct should just be called Progress
pub seconds_remaining: u64, | ||
} | ||
|
||
pub struct DscProgressBar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be ProgressBar
PR Summary
Fix #592
-f, --format
argument todsc.exe
isjson
orpretty-json
.Searching for adapted resources
progress which previously was always showing 0.The structure of json progress message is following.
activity
andpercent_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).Dev notes:
struct DscProgressBar
which is wrapping both UI progress bar and json serialization;pub enum OutputFormat
fromdsc
todsc_lib
and updated all references.