Skip to content

Commit

Permalink
moss/cli/state: Emit creation timestamp with local timezone (fixes #346)
Browse files Browse the repository at this point in the history
As a temporary fix for the "description" issue being useless, we only emit it
when a description is present. Which right now, is never.

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Nov 8, 2024
1 parent a344a80 commit f39fa05
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions moss/src/cli/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: MPL-2.0

use chrono::Local;
use clap::{arg, ArgAction, ArgMatches, Command};
use moss::{
client::{self, prune, Client},
Expand Down Expand Up @@ -141,19 +142,18 @@ pub fn verify(args: &ArgMatches, installation: Installation) -> Result<(), Error

/// Emit a state description for the TUI
fn print_state(state: state::State) {
let local_time = state.created.with_timezone(&Local);
let formatted_time = local_time.format("%Y-%m-%d %H:%M:%S %Z");

println!(
"State #{} - {}",
state.id.to_string().bold(),
state.summary.unwrap_or(String::from("system transaction")),
);
println!("{} {}", "Created:".bold(), state.created);
println!(
"{} {}",
"Description:".bold(),
state.description.unwrap_or(String::from("no description"))
state.summary.unwrap_or_else(|| String::from("system transaction"))
);
// TODO: List packages?
// TODO: Start with normal list, compute diff, reverse to print ?
println!("{} {}", "Created:".bold(), formatted_time);
if let Some(desc) = &state.description {
println!("{} {}", "Description:".bold(), desc);
}
println!("{} {}", "Packages:".bold(), state.selections.len());
println!();
}
Expand Down

0 comments on commit f39fa05

Please sign in to comment.