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

Move snapshot output to the rich output system. #1524

Closed
wants to merge 2 commits into from
Closed

Conversation

fnando
Copy link
Member

@fnando fnando commented Aug 6, 2024

What

output.mp4

Why

So we have one standardized way of doing it.

Known limitations

N/A

@fnando fnando requested a review from leighmcculloch August 6, 2024 18:36
@fnando fnando enabled auto-merge (squash) August 6, 2024 19:22
Json,
}

impl Default for Output {
impl Default for OutputFile {
Copy link
Member

Choose a reason for hiding this comment

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

We use the term Output elsewhere for the output type, where the output isn't a file, could we keep it as is, and change the output module to print since it's for printing specifically?

print!("🪣 Downloading bucket {bucket_index} {bucket}");
let message = format!("Downloading bucket {bucket_index} {bucket}");

output.print("🪣", format!("{message}…"), false);
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a .bucket function instead of hardcoding this one emoji unlike the others?

Comment on lines +19 to +27
pub fn print<T: Display>(&self, icon: &str, message: T, new_line: bool) {
if self.quiet {
return;
}

if new_line {
eprintln!("{icon} {message}");
} else {
eprint!("{icon} {message}");
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with the Rust stdlib, it'd be helpful if we operated the newline option via different function names, print and println like:

Other functions can then also get two variants, check and checkln.

Then I think we don't need the icon parameter to print and it can simply accept a &str (or preferably a Display). For example, the use would be:

output.globeln(format!("Downloading history {history_url}"));
...
output.bucket(format!("Downloading bucket {bucket_index} {bucket}…"));
...
output.println("({size})");

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we actually need this, because most of these functions won't be used without the line break. The idea was just supporting the minority of cases via the centralized print function. I get the pattern, but I think in this case is too much.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also wonder if we should use a macro to generate these functions, as they're essentially the same thing.

@fnando
Copy link
Member Author

fnando commented Aug 7, 2024

Close in favor of #1531

@fnando fnando closed this Aug 7, 2024
auto-merge was automatically disabled August 7, 2024 20:45

Pull request was closed

@fnando fnando deleted the snapshot-output branch August 7, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants