cli: Flesh out `rad self`
This commit is contained in:
parent
fdd6bca311
commit
13998dcf46
|
|
@ -17,7 +17,7 @@ You can get the above information at all times using the `self` command:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ rad self
|
$ rad self
|
||||||
ID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
Node ID z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
Node ID z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA
|
Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA
|
||||||
Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
|
Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
The `rad self` command is used to display information about your local
|
||||||
|
device and node.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rad self
|
||||||
|
DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
|
Node ID z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
|
Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA
|
||||||
|
Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
|
||||||
|
Storage (git) [..]
|
||||||
|
Storage (keys) [..]
|
||||||
|
Node (socket) [..]
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need to display only your DID, Node ID, or SSH Public Key, you can use
|
||||||
|
the various options available:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rad self --did
|
||||||
|
did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rad self --nid
|
||||||
|
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rad self --ssh-key
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
|
||||||
|
```
|
||||||
|
|
@ -17,14 +17,20 @@ Usage
|
||||||
|
|
||||||
Options
|
Options
|
||||||
|
|
||||||
--id Show ID
|
--nid Show your Node ID
|
||||||
--help Show help
|
--did Show your DID
|
||||||
|
--ssh-key Show your public key in OpenSSH format
|
||||||
|
--ssh-fingerprint Show your public key fingerprint in OpenSSH format
|
||||||
|
--help Show help
|
||||||
"#,
|
"#,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Show {
|
enum Show {
|
||||||
Id,
|
NodeId,
|
||||||
|
Did,
|
||||||
|
SshKey,
|
||||||
|
SshFingerprint,
|
||||||
All,
|
All,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,8 +48,17 @@ impl Args for Options {
|
||||||
|
|
||||||
while let Some(arg) = parser.next()? {
|
while let Some(arg) = parser.next()? {
|
||||||
match arg {
|
match arg {
|
||||||
Long("id") if show.is_none() => {
|
Long("nid") if show.is_none() => {
|
||||||
show = Some(Show::Id);
|
show = Some(Show::NodeId);
|
||||||
|
}
|
||||||
|
Long("did") if show.is_none() => {
|
||||||
|
show = Some(Show::Did);
|
||||||
|
}
|
||||||
|
Long("ssh-key") if show.is_none() => {
|
||||||
|
show = Some(Show::SshKey);
|
||||||
|
}
|
||||||
|
Long("ssh-fingerprint") if show.is_none() => {
|
||||||
|
show = Some(Show::SshFingerprint);
|
||||||
}
|
}
|
||||||
Long("help") => {
|
Long("help") => {
|
||||||
return Err(Error::Help.into());
|
return Err(Error::Help.into());
|
||||||
|
|
@ -65,9 +80,18 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let profile = ctx.profile()?;
|
let profile = ctx.profile()?;
|
||||||
|
|
||||||
match options.show {
|
match options.show {
|
||||||
Show::Id => {
|
Show::NodeId => {
|
||||||
term::print(profile.id());
|
term::print(profile.id());
|
||||||
}
|
}
|
||||||
|
Show::Did => {
|
||||||
|
term::print(profile.did());
|
||||||
|
}
|
||||||
|
Show::SshKey => {
|
||||||
|
term::print(ssh::fmt::key(profile.id()));
|
||||||
|
}
|
||||||
|
Show::SshFingerprint => {
|
||||||
|
term::print(ssh::fmt::fingerprint(profile.id()));
|
||||||
|
}
|
||||||
Show::All => all(&profile)?,
|
Show::All => all(&profile)?,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +103,7 @@ fn all(profile: &Profile) -> anyhow::Result<()> {
|
||||||
|
|
||||||
let did = profile.did();
|
let did = profile.did();
|
||||||
table.push([
|
table.push([
|
||||||
term::format::style("ID").to_string(),
|
term::format::style("DID").to_string(),
|
||||||
term::format::tertiary(did).to_string(),
|
term::format::tertiary(did).to_string(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,15 @@ fn rad_clone() {
|
||||||
test("examples/rad-clone.md", working, Some(&bob.home), []).unwrap();
|
test("examples/rad-clone.md", working, Some(&bob.home), []).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rad_self() {
|
||||||
|
let mut environment = Environment::new();
|
||||||
|
let alice = environment.node("alice");
|
||||||
|
let working = environment.tmp().join("working");
|
||||||
|
|
||||||
|
test("examples/rad-self.md", working, Some(&alice.home), []).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rad_clone_unknown() {
|
fn rad_clone_unknown() {
|
||||||
logger::init(log::Level::Debug);
|
logger::init(log::Level::Debug);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue