diff --git a/radicle-cli/src/commands/self.rs b/radicle-cli/src/commands/self.rs index 53d320a9..9dbe01d8 100644 --- a/radicle-cli/src/commands/self.rs +++ b/radicle-cli/src/commands/self.rs @@ -78,33 +78,30 @@ fn all(profile: &Profile) -> anyhow::Result<()> { let mut table = term::Table::default(); let node_id = profile.id(); - table.push([String::from("ID"), term::format::tertiary(node_id)]); + table.push(["ID", &term::format::tertiary(node_id)]); let ssh_short = ssh::fmt::fingerprint(node_id); - table.push([ - String::from("Key (hash)"), - term::format::tertiary(ssh_short), - ]); + table.push(["Key (hash)", &term::format::tertiary(ssh_short)]); let ssh_long = ssh::fmt::key(node_id); - table.push([String::from("Key (full)"), term::format::tertiary(ssh_long)]); + table.push(["Key (full)", &term::format::tertiary(ssh_long)]); let storage_path = profile.paths().storage(); table.push([ - String::from("Storage (git)"), - term::format::tertiary(storage_path.display()), + "Storage (git)", + &term::format::tertiary(storage_path.display()), ]); let keys_path = profile.paths().keys(); table.push([ - String::from("Storage (keys)"), - term::format::tertiary(keys_path.display()), + "Storage (keys)", + &term::format::tertiary(keys_path.display()), ]); let node_path = profile.paths().node(); table.push([ - String::from("Node (socket)"), - term::format::tertiary(node_path.join("radicle.sock").display()), + "Node (socket)", + &term::format::tertiary(node_path.join("radicle.sock").display()), ]); table.render(); diff --git a/radicle-cli/src/terminal/table.rs b/radicle-cli/src/terminal/table.rs index 4cc8f8f2..c3cd17d1 100644 --- a/radicle-cli/src/terminal/table.rs +++ b/radicle-cli/src/terminal/table.rs @@ -5,13 +5,13 @@ //! use radicle_cli::terminal::table::*; //! //! let mut t = Table::new(TableOptions::default()); -//! t.push(["pest".to_string(), "biological control".to_string()]); -//! t.push(["aphid".to_string(), "lacewing".to_string()]); -//! t.push(["spider mite".to_string(), "ladybug".to_string()]); +//! t.push(["pest", "biological control"]); +//! t.push(["aphid", "lacewing"]); +//! t.push(["spider mite", "ladybug"]); //! t.render(); //! // pest biological control -//! // aphid lacewing -//! // spider mite ladybug +//! // aphid ladybug +//! // spider mite persimilis //! ``` use std::fmt::Write; @@ -49,7 +49,8 @@ impl Table { } } - pub fn push(&mut self, row: [String; W]) { + pub fn push(&mut self, row: [impl ToString; W]) { + let row = row.map(|s| s.to_string()); for (i, cell) in row.iter().enumerate() { self.widths[i] = self.widths[i].max(console::measure_text_width(cell)); }