cli: Add user alias to `rad auth`
We were outputting `(me)` previously.
This commit is contained in:
parent
8c701dc908
commit
074b0e55c1
|
|
@ -4,7 +4,7 @@ pub use radicle_term::format::*;
|
||||||
pub use radicle_term::{style, Paint};
|
pub use radicle_term::{style, Paint};
|
||||||
|
|
||||||
use radicle::cob::{ObjectId, Timestamp};
|
use radicle::cob::{ObjectId, Timestamp};
|
||||||
use radicle::node::NodeId;
|
use radicle::node::{AliasStore, NodeId};
|
||||||
use radicle::prelude::Did;
|
use radicle::prelude::Did;
|
||||||
use radicle::profile::Profile;
|
use radicle::profile::Profile;
|
||||||
|
|
||||||
|
|
@ -116,22 +116,25 @@ impl<'a> Identity<'a> {
|
||||||
|
|
||||||
impl<'a> fmt::Display for Identity<'a> {
|
impl<'a> fmt::Display for Identity<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let username = "(me)";
|
let nid = self.profile.id();
|
||||||
|
let alias = self.profile.aliases().ok().and_then(|a| a.alias(nid));
|
||||||
let node_id = match self.short {
|
let node_id = match self.short {
|
||||||
true => self::node(self.profile.id()),
|
true => self::node(nid),
|
||||||
false => self.profile.id().to_human(),
|
false => nid.to_human(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.styled {
|
if self.styled {
|
||||||
write!(
|
write!(f, "{}", term::format::highlight(node_id))?;
|
||||||
f,
|
if let Some(a) = alias {
|
||||||
"{} {}",
|
write!(f, " {}", term::format::parens(term::format::dim(a)))?;
|
||||||
term::format::highlight(node_id),
|
}
|
||||||
term::format::dim(username)
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{node_id} {username}")
|
write!(f, "{node_id}")?;
|
||||||
|
if let Some(a) = alias {
|
||||||
|
write!(f, " ({a})")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue