Skip to content

Commit

Permalink
Print project names more nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
milliams committed Jul 11, 2024
1 parent 8b87c78 commit 1f75f2d
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,28 @@ fn main() -> Result<()> {
Ok,
)
.context("Could not get certificate.")?;
let projects = &cert
.projects
.iter()
.map(|p| p.short_name.clone())
.collect::<Vec<_>>()
.join(" ");
println!("Authenticated as {} for projects: {}", &cert.user, projects);
match cert.projects.as_slice() {
[p] => {
println!(
"Authenticated as {} for project {}\n",
&cert.user, p.short_name
);
}
projects @ [_, ..] => {
let projects = projects
.iter()
.map(|p| format!(" - {}", &p.short_name))
.collect::<Vec<_>>()
.join("\n");
println!(
"Authenticated as {} for projects:\n{}\n",
&cert.user, projects
);
}
[] => {
anyhow::bail!("Did not authenticate with any projects.")
}
}
std::fs::write(&cert_file_path, format!("{}\n", &cert.certificate))
.context("Could not write certificate file.")?;
std::fs::write(&cert_details_file_path, serde_json::to_string(&cert)?)
Expand Down

0 comments on commit 1f75f2d

Please sign in to comment.