freenet / freenet-core

Declare your digital independence
https://freenet.org/
Apache License 2.0
2.28k stars 79 forks source link

runtime error from clap #1312

Open rhizoome opened 1 day ago

rhizoome commented 1 day ago

I get a runtime error from clap:

 cargo run --locked --bin freenet
Command freenet: Argument names must be unique, but 'address' is in use by more than one argument or group
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I fixed the problem, but the code is like that since a very long time. So I assume it is working for everybody else, that is why I did not create a pull-request.

diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs
index 7f90315e..d1cac401 100644
--- a/crates/core/src/config.rs
+++ b/crates/core/src/config.rs
@@ -377,7 +377,7 @@ impl Config {
 #[derive(clap::Parser, Debug, Default, Copy, Clone, Serialize, Deserialize)]
 pub struct NetworkArgs {
     /// Address to bind to for the network event listener, default is 0.0.0.0
-    #[arg(long = "network-address", env = "NETWORK_ADDRESS")]
+    #[arg(name = "network_address", long = "network-address", env = "NETWORK_ADDRESS")]
     #[serde(rename = "network-address", skip_serializing_if = "Option::is_none")]
     pub address: Option<IpAddr>,

@@ -436,7 +436,7 @@ const fn default_network_port() -> u16 {
 #[derive(clap::Parser, Debug, Default, Copy, Clone, Serialize, Deserialize)]
 pub struct WebsocketApiArgs {
     /// Address to bind to for the websocket API, default is 0.0.0.0
-    #[arg(long = "ws-api-address", env = "WS_API_ADDRESS")]
+    #[arg(name = "ws_api_address", long = "ws-api-address", env = "WS_API_ADDRESS")]
     #[serde(rename = "ws-api-address", skip_serializing_if = "Option::is_none")]
     pub address: Option<IpAddr>,
sanity commented 1 day ago

cc: @iduartgomez