cli: Add `rad node inventory` command
Prints the local node's inventory.
This commit is contained in:
parent
50379548c2
commit
fc55d67929
|
|
@ -5,6 +5,7 @@ use std::time;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
|
||||||
use radicle::node::config::ConnectAddress;
|
use radicle::node::config::ConnectAddress;
|
||||||
|
use radicle::node::routing::Store;
|
||||||
use radicle::node::Handle as _;
|
use radicle::node::Handle as _;
|
||||||
use radicle::node::{Address, Node, NodeId, PeerAddr};
|
use radicle::node::{Address, Node, NodeId, PeerAddr};
|
||||||
use radicle::prelude::RepoId;
|
use radicle::prelude::RepoId;
|
||||||
|
|
@ -36,6 +37,7 @@ Usage
|
||||||
rad node debug [<option>...]
|
rad node debug [<option>...]
|
||||||
rad node connect <nid>@<addr> [<option>...]
|
rad node connect <nid>@<addr> [<option>...]
|
||||||
rad node routing [--rid <rid>] [--nid <nid>] [--json] [<option>...]
|
rad node routing [--rid <rid>] [--nid <nid>] [--json] [<option>...]
|
||||||
|
rad node inventory [<option>...]
|
||||||
rad node events [--timeout <secs>] [-n <count>] [<option>...]
|
rad node events [--timeout <secs>] [-n <count>] [<option>...]
|
||||||
rad node config [--addresses]
|
rad node config [--addresses]
|
||||||
rad node db <command> [<option>..]
|
rad node db <command> [<option>..]
|
||||||
|
|
@ -99,6 +101,7 @@ pub enum Operation {
|
||||||
lines: usize,
|
lines: usize,
|
||||||
},
|
},
|
||||||
Status,
|
Status,
|
||||||
|
Inventory,
|
||||||
Debug,
|
Debug,
|
||||||
Sessions,
|
Sessions,
|
||||||
Stop,
|
Stop,
|
||||||
|
|
@ -115,6 +118,7 @@ pub enum OperationName {
|
||||||
Start,
|
Start,
|
||||||
#[default]
|
#[default]
|
||||||
Status,
|
Status,
|
||||||
|
Inventory,
|
||||||
Debug,
|
Debug,
|
||||||
Sessions,
|
Sessions,
|
||||||
Stop,
|
Stop,
|
||||||
|
|
@ -151,6 +155,7 @@ impl Args for Options {
|
||||||
"logs" => op = Some(OperationName::Logs),
|
"logs" => op = Some(OperationName::Logs),
|
||||||
"config" => op = Some(OperationName::Config),
|
"config" => op = Some(OperationName::Config),
|
||||||
"routing" => op = Some(OperationName::Routing),
|
"routing" => op = Some(OperationName::Routing),
|
||||||
|
"inventory" => op = Some(OperationName::Inventory),
|
||||||
"start" => op = Some(OperationName::Start),
|
"start" => op = Some(OperationName::Start),
|
||||||
"status" => op = Some(OperationName::Status),
|
"status" => op = Some(OperationName::Status),
|
||||||
"stop" => op = Some(OperationName::Stop),
|
"stop" => op = Some(OperationName::Stop),
|
||||||
|
|
@ -225,6 +230,7 @@ impl Args for Options {
|
||||||
options,
|
options,
|
||||||
path: path.unwrap_or(PathBuf::from("radicle-node")),
|
path: path.unwrap_or(PathBuf::from("radicle-node")),
|
||||||
},
|
},
|
||||||
|
OperationName::Inventory => Operation::Inventory,
|
||||||
OperationName::Status => Operation::Status,
|
OperationName::Status => Operation::Status,
|
||||||
OperationName::Debug => Operation::Debug,
|
OperationName::Debug => Operation::Debug,
|
||||||
OperationName::Sessions => Operation::Sessions,
|
OperationName::Sessions => Operation::Sessions,
|
||||||
|
|
@ -280,6 +286,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
} => {
|
} => {
|
||||||
control::start(node, !foreground, verbose, options, &path, &profile)?;
|
control::start(node, !foreground, verbose, options, &path, &profile)?;
|
||||||
}
|
}
|
||||||
|
Operation::Inventory => {
|
||||||
|
for rid in profile.routing()?.get_inventory(profile.id())? {
|
||||||
|
println!("{}", term::format::tertiary(rid));
|
||||||
|
}
|
||||||
|
}
|
||||||
Operation::Status => {
|
Operation::Status => {
|
||||||
control::status(&node, &profile)?;
|
control::status(&node, &profile)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -652,6 +652,11 @@ impl Home {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the routing store.
|
/// Returns the routing store.
|
||||||
|
pub fn routing(&self) -> Result<impl node::routing::Store, node::db::Error> {
|
||||||
|
self.database()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the routing store, mutably.
|
||||||
pub fn routing_mut(&self) -> Result<impl node::routing::Store, node::db::Error> {
|
pub fn routing_mut(&self) -> Result<impl node::routing::Store, node::db::Error> {
|
||||||
self.database_mut()
|
self.database_mut()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue