Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
### Changes

- CLI
- Extract `doublezero-daemon-cli` crate housing `DaemonClient` trait and the `status`, `enable`, `disable`, `latency`, and `routes` daemon verbs. The new crate owns all daemon HTTP interaction (Unix-socket client, response types) and is consumed by the `doublezero` binary. `check_daemon` binds `get_environment()` once per invocation instead of calling it per-check.
- Fold `version`, `account`, `accounts`, `log`, and `subscribe` diagnostic verbs from the binary's top-level `Command` enum into `ServiceabilityCommand` per RFC-20. Each verb now takes `&CliContext` + generic `&C: CliCommand` + `&mut W` writer and is async. Add `--json` to `account`, `accounts`, and `log` (RFC-20 §Output). The binary-level `subscribe` override uses the real blocking `DZClient::subscribe` for live event streaming; the module crate's implementation falls back to a `get_all()` snapshot for testability.
- Change `geolocation user update-payment` to `update-payment-status` for clarity.
- geolocation `user get`: Show probe code, rather than probe pubkey in target list.
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions client/doublezero/src/cli/command.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use clap::{Args, Subcommand};
use clap_complete::Shell;
use doublezero_daemon_cli::DaemonCommand;
use doublezero_geolocation_cli::GeolocationArgs;
use doublezero_serviceability_cli::cli::ServiceabilityCommand;

use crate::{
cli::multicast::MulticastCliCommand,
command::{
connect::ProvisioningCliCommand, disable::DisableCliCommand,
disconnect::DecommissioningCliCommand, enable::EnableCliCommand,
connect::ProvisioningCliCommand, disconnect::DecommissioningCliCommand,
latency::LatencyCliCommand, routes::RoutesCliCommand, status::StatusCliCommand,
},
};

/// Top-level command tree for the unified `doublezero` binary.
///
/// Per RFC-20 §Module contract item 2, the serviceability verbs live in
/// `doublezero_serviceability_cli::cli::ServiceabilityCommand` and are hoisted
/// to the top level here via `#[command(flatten)]`. The binary retains the
/// Per RFC-20 §Module contract item 2, module-crate verbs are hoisted to the
/// top level via `#[command(flatten)]`: serviceability verbs from
/// `doublezero_serviceability_cli`, daemon-control verbs (`enable`, `disable`)
/// from `doublezero_daemon_cli`. The binary retains the not-yet-migrated
/// daemon-control verbs, the `doublezero-geolocation-cli` module crate's
/// geolocation subtree (via `GeolocationArgs`), the binary-only `Completion`
/// generator, and `Multicast` (whose `Subscribe`/`Unsubscribe`/`Publish`/
Expand All @@ -25,10 +26,12 @@ use crate::{
pub enum Command {
/// Connect your server to a doublezero device
Connect(ProvisioningCliCommand),
/// Enable the reconciler (start managing tunnels)
Enable(EnableCliCommand),
/// Disable the reconciler (tear down tunnels and stop managing them)
Disable(DisableCliCommand),

/// Daemon-control verbs migrated to `doublezero-daemon-cli` (RFC-20).
/// Hoisted to top-level via `#[command(flatten)]`.
#[command(flatten)]
Daemon(DaemonCommand),

/// Get the status of your service
Status(StatusCliCommand),
/// Disconnect your server from the doublezero network
Expand Down
118 changes: 0 additions & 118 deletions client/doublezero/src/command/disable.rs

This file was deleted.

111 changes: 0 additions & 111 deletions client/doublezero/src/command/enable.rs

This file was deleted.

2 changes: 0 additions & 2 deletions client/doublezero/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub mod connect;
pub mod disable;
pub mod disconnect;
pub mod enable;
pub mod helpers;
pub mod latency;
pub mod multicast;
Expand Down
37 changes: 32 additions & 5 deletions client/doublezero/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,32 @@ mod requirements;
mod servicecontroller;
use crate::cli::{command::Command, multicast::MulticastCommands};
use doublezero_cli_core::LogLevel;
use doublezero_daemon_cli::{DaemonClientImpl, DaemonCommand};
use doublezero_geolocation_cli::GeoCliCommandImpl;
use doublezero_sdk::{
convert_geo_program_moniker, convert_program_moniker, geolocation::client::GeoClient, DZClient,
ProgramVersion,
};
use doublezero_serviceability::pda::get_globalstate_pda;
use doublezero_serviceability_cli::{
checkversion::check_version, cli::ServiceabilityCommand, doublezerocommand::CliCommandImpl,
checkversion::check_version,
cli::ServiceabilityCommand,
doublezerocommand::{CliCommand, CliCommandImpl},
};
use servicecontroller::ServiceControllerImpl;

/// Adapter bridging the binary's `CliCommand` to the daemon-cli crate's
/// `LedgerClient` trait.
struct LedgerAdapter {
env: Environment,
}

impl doublezero_daemon_cli::LedgerClient for LedgerAdapter {
fn get_environment(&self) -> Environment {
self.env
}
}

#[derive(Parser, Debug)]
#[command(term_width = 0)]
#[command(name = "DoubleZero")]
Expand Down Expand Up @@ -136,6 +151,7 @@ async fn main() -> eyre::Result<()> {

if let Some(sock_file) = &app.sock_file {
ServiceControllerImpl::set_global_socket_path(sock_file.to_string_lossy());
DaemonClientImpl::set_global_socket_path(sock_file.to_string_lossy());
}

if let Some(keypair) = &app.keypair {
Expand Down Expand Up @@ -264,8 +280,7 @@ async fn main() -> eyre::Result<()> {
let skip_version_check = matches!(
&command,
Command::Status(_)
| Command::Enable(_)
| Command::Disable(_)
| Command::Daemon(DaemonCommand::Enable(_) | DaemonCommand::Disable(_))
| Command::Completion(_)
| Command::Serviceability(
ServiceabilityCommand::Address(_)
Expand All @@ -283,8 +298,20 @@ async fn main() -> eyre::Result<()> {
let res = match command {
// Daemon-control verbs (binary-local)
Command::Connect(args) => args.execute(&client).await,
Command::Enable(args) => args.execute(&client).await,
Command::Disable(args) => args.execute(&client).await,

// Daemon-control verbs migrated to doublezero-daemon-cli (RFC-20)
Command::Daemon(cmd) => {
let daemon = DaemonClientImpl::new(
ctx.daemon_socket_path
.as_ref()
.map(|p| p.to_string_lossy().into_owned()),
);
let ledger = LedgerAdapter {
env: client.get_environment(),
};
cmd.execute(&ctx, &daemon, &ledger, &mut handle).await
}

Command::Status(args) => args.execute(&client).await,
Command::Disconnect(args) => args.execute(&client).await,
Command::Latency(args) => args.execute(&client).await,
Expand Down
Loading
Loading