summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs8
-rw-r--r--src/commands/profile.rs13
2 files changed, 21 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d1edb3c..3041e33 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -41,6 +41,14 @@ pub fn app<'a>() -> App<'a> {
.value_name("NAME")
.about("Name of the profile")
)
+
+ .arg(Arg::with_name("connect")
+ .long("connect")
+ .required(false)
+ .takes_value(true)
+ .value_name("MULTIADDR")
+ .about("Connect to MULTIADDR as well")
+ )
)
)
}
diff --git a/src/commands/profile.rs b/src/commands/profile.rs
index 93753d7..4da70f1 100644
--- a/src/commands/profile.rs
+++ b/src/commands/profile.rs
@@ -31,12 +31,25 @@ async fn profile_create(matches: &ArgMatches) -> Result<()> {
}
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 state_dir = Profile::state_dir_path(&name)?;
log::info!("Loading '{}' from {}", name, state_dir.display());
let profile = Profile::load(Config::default(), &name).await?;
log::info!("Profile loaded");
+ log::info!("Profile HEAD = {}", profile.head());
+
+ if let Some(connect_to) = connect_peer {
+ log::info!("Connecting to {:?}", connect_to);
+ profile.connect(connect_to).await?;
+ }
let running = Arc::new(AtomicBool::new(true));
let r = running.clone();