mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-19 10:23:42 -05:00
Added metrics to JSON, switched from json to serde_json, extracted all JSON related functionality into a function in utils.rs
Some checks are pending
Nightly Release / build-binary (map[bin:cup command:build name:cup-linux-aarch64 os:ubuntu-latest release_for:linux-aarch64 target:aarch64-unknown-linux-musl]) (push) Waiting to run
Nightly Release / build-binary (map[bin:cup command:build name:cup-linux-x86_64 os:ubuntu-latest release_for:linux-x86_64 target:x86_64-unknown-linux-musl]) (push) Waiting to run
Nightly Release / build-image (push) Waiting to run
Some checks are pending
Nightly Release / build-binary (map[bin:cup command:build name:cup-linux-aarch64 os:ubuntu-latest release_for:linux-aarch64 target:aarch64-unknown-linux-musl]) (push) Waiting to run
Nightly Release / build-binary (map[bin:cup command:build name:cup-linux-x86_64 os:ubuntu-latest release_for:linux-x86_64 target:x86_64-unknown-linux-musl]) (push) Waiting to run
Nightly Release / build-image (push) Waiting to run
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use json::object;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::utils::sort_update_vec;
|
||||
use crate::utils::{sort_update_vec, to_json};
|
||||
|
||||
pub fn print_updates(updates: &[(String, Option<bool>)], icons: &bool) {
|
||||
let sorted_updates = sort_update_vec(updates);
|
||||
@@ -40,11 +40,7 @@ pub fn print_updates(updates: &[(String, Option<bool>)], icons: &bool) {
|
||||
}
|
||||
|
||||
pub fn print_raw_updates(updates: &[(String, Option<bool>)]) {
|
||||
let mut result = json::Array::new();
|
||||
for update in updates {
|
||||
result.push(object! {image: update.0.clone(), has_update: update.1});
|
||||
}
|
||||
println!("{}", json::stringify(result));
|
||||
println!("{}", serde_json::to_string(&to_json(updates)).unwrap());
|
||||
}
|
||||
|
||||
pub fn print_update(name: &str, has_update: &Option<bool>) {
|
||||
@@ -62,8 +58,8 @@ pub fn print_update(name: &str, has_update: &Option<bool>) {
|
||||
}
|
||||
|
||||
pub fn print_raw_update(name: &str, has_update: &Option<bool>) {
|
||||
let result = object!{image: name, has_update: *has_update};
|
||||
println!("{}", json::stringify(result));
|
||||
let result = json!({"images": {name: has_update}});
|
||||
println!("{}", result);
|
||||
}
|
||||
|
||||
pub struct Spinner {
|
||||
|
||||
Reference in New Issue
Block a user