diff options
-rw-r--r-- | cli/src/cli.rs | 1 | ||||
-rw-r--r-- | cli/src/profile.rs | 18 |
2 files changed, 13 insertions, 6 deletions
diff --git a/cli/src/cli.rs b/cli/src/cli.rs index ee8d608..4b0b0f5 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -46,6 +46,7 @@ pub fn app<'a>() -> App<'a> { .long("connect") .required(false) .takes_value(true) + .multiple(true) .value_name("MULTIADDR") .about("Connect to MULTIADDR as well") ) diff --git a/cli/src/profile.rs b/cli/src/profile.rs index 87b1e54..c239bc5 100644 --- a/cli/src/profile.rs +++ b/cli/src/profile.rs @@ -36,10 +36,14 @@ async fn profile_serve(matches: &ArgMatches) -> Result<()> { use ipfs::MultiaddrWithPeerId; let name = matches.value_of("name").map(String::from).unwrap(); // required - let connect_peer = matches.value_of("connect").map(|s| { - s.parse::<MultiaddrWithPeerId>() - .map_err(anyhow::Error::from) - }).transpose()?; + let connect_peer = matches.values_of("connect") + .map(|v| { + v.map(|s| { + s.parse::<MultiaddrWithPeerId>().map_err(anyhow::Error::from) + }) + .collect::<Result<Vec<_>>>() + }) + .transpose()?; let state_dir = Profile::state_dir_path(&name)?; @@ -51,8 +55,10 @@ async fn profile_serve(matches: &ArgMatches) -> Result<()> { } if let Some(connect_to) = connect_peer { - log::info!("Connecting to {:?}", connect_to); - profile.connect(connect_to).await?; + for c in connect_to { + log::info!("Connecting to {:?}", c); + profile.connect(c).await?; + } } let running = Arc::new(AtomicBool::new(true)); |