refactor: Remove networking flag from CLI commands and documentation

- Eliminated the `--enable-networking` flag from the `start` and `restart` commands in the CLI, simplifying the command structure.
- Updated related documentation to reflect the removal of the networking option, ensuring consistency across usage examples.
- Adjusted the daemon to always enable networking, streamlining the startup process for users.
This commit is contained in:
Jamie Pine 2025-09-19 19:28:21 -07:00
parent b52e307e33
commit 8465b50885
5 changed files with 22 additions and 49 deletions

View File

@ -123,9 +123,6 @@ struct Cli {
enum Commands {
/// Start the Spacedrive daemon
Start {
/// Automatically start networking
#[arg(long)]
enable_networking: bool,
/// Run daemon in foreground (show logs)
#[arg(long)]
foreground: bool,
@ -138,9 +135,6 @@ enum Commands {
},
/// Restart the Spacedrive daemon
Restart {
/// Automatically start networking after restart
#[arg(long)]
enable_networking: bool,
/// Run daemon in foreground after restart (show logs)
#[arg(long)]
foreground: bool,
@ -200,10 +194,7 @@ async fn main() -> Result<()> {
};
match cli.command {
Commands::Start {
enable_networking,
foreground,
} => {
Commands::Start { foreground } => {
crate::ui::print_compact_logo();
println!("Starting daemon...");
@ -233,11 +224,6 @@ async fn main() -> Result<()> {
command.arg("--instance").arg(inst);
}
// Pass networking flag if enabled
if enable_networking {
command.arg("--enable-networking");
}
// Set working directory to current directory
command.current_dir(std::env::current_dir()?);
@ -323,11 +309,7 @@ async fn main() -> Result<()> {
reset_spacedrive_v2_data(&data_dir)?;
}
}
Commands::Restart {
enable_networking,
foreground,
reset,
} => {
Commands::Restart { foreground, reset } => {
if reset {
use crate::util::confirm::confirm_or_abort;
confirm_or_abort(
@ -362,10 +344,6 @@ async fn main() -> Result<()> {
let mut cmd = std::process::Command::new(std::env::current_exe()?);
cmd.arg("start");
if enable_networking {
cmd.arg("--enable-networking");
}
if foreground {
cmd.arg("--foreground");
// Run in foreground - this will block

View File

@ -36,7 +36,7 @@ impl fmt::Display for CliError {
write!(f, "To start the daemon, run:\n")?;
write!(f, " sd start\n\n")?;
write!(f, " Or start with networking enabled:\n")?;
write!(f, " sd start --enable-networking")
write!(f, " sd start")
},
Self::CoreError(msg) => write!(f, "Core operation failed: {}", msg),
Self::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
@ -64,17 +64,17 @@ pub type CliResult<T> = Result<T, CliError>;
/// Check if an error message indicates the daemon is not running
pub fn is_daemon_connection_error(error_msg: &str) -> bool {
error_msg.contains("Failed to connect to daemon socket")
|| error_msg.contains("Connection refused")
|| error_msg.contains("No such file or directory")
|| error_msg.contains("daemon socket")
error_msg.contains("Failed to connect to daemon socket")
|| error_msg.contains("Connection refused")
|| error_msg.contains("No such file or directory")
|| error_msg.contains("daemon socket")
}
/// Convert a core error to a more user-friendly CLI error
pub fn improve_core_error(error_msg: String) -> CliError {
if is_daemon_connection_error(&error_msg) {
CliError::DaemonNotRunning
} else {
CliError::CoreError(error_msg)
}
if is_daemon_connection_error(&error_msg) {
CliError::DaemonNotRunning
} else {
CliError::CoreError(error_msg)
}
}

View File

@ -28,10 +28,6 @@ struct Args {
/// Daemon instance name
#[arg(long)]
instance: Option<String>,
/// Enable networking
#[arg(long)]
enable_networking: bool,
}
#[tokio::main]
@ -46,8 +42,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Calculate socket path based on instance
let socket_path = if let Some(instance) = args.instance {
// Validate instance name for security
validate_instance_name(&instance)
.map_err(|e| format!("Invalid instance name: {}", e))?;
validate_instance_name(&instance).map_err(|e| format!("Invalid instance name: {}", e))?;
data_dir
.join("daemon")
.join(format!("daemon-{}.sock", instance))
@ -58,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
sd_core::infra::daemon::bootstrap::start_default_server(
socket_path,
data_dir,
args.enable_networking,
true, // Always enable networking
)
.await
}

View File

@ -23,8 +23,8 @@ spacedrive start --instance alice
spacedrive start --instance bob
# Start with networking enabled
spacedrive start --instance alice --enable-networking
spacedrive start --instance bob --enable-networking
spacedrive start --instance alice
spacedrive start --instance bob
```
### Targeting Specific Instances
@ -60,10 +60,10 @@ Test device pairing locally using two instances:
```bash
# Terminal 1: Start Alice's daemon
spacedrive start --instance alice --enable-networking --foreground
spacedrive start --instance alice --foreground
# Terminal 2: Start Bob's daemon
spacedrive start --instance bob --enable-networking --foreground
spacedrive start --instance bob --foreground
# Terminal 3: Alice generates pairing code
spacedrive --instance alice network init --password "test123"
@ -118,8 +118,8 @@ data/sd-cli-data/instance-bob/ # Bob instance data
```bash
# Start two instances for pairing test
spacedrive start --instance initiator --enable-networking --foreground &
spacedrive start --instance joiner --enable-networking --foreground &
spacedrive start --instance initiator --foreground &
spacedrive start --instance joiner --foreground &
# Initialize networking
spacedrive --instance initiator network init --password "dev123"

View File

@ -82,7 +82,7 @@ sd status
sd start
# Start daemon with networking enabled
sd start --enable-networking
sd start
# Start daemon in foreground (for debugging)
sd start --foreground
@ -269,7 +269,7 @@ sd system logs --tail 50
### Networking & Device Management
```bash
# Initialize networking (if daemon wasn't started with --enable-networking)
# Initialize networking (if daemon wasn't started with)
sd network init
# Start/stop networking