Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Add interactive step for announce during init
◌ CI pending Adrian Duke committed 2 months ago
commit 94f6f11ff86ab5022a88cc035e2746aab907c286
parent cf8f86a300745a800fa3ba44cbede6d7a7d4ab24
1 pending (1 total) View logs
2 files changed +17 -7
modified crates/radicle-cli/src/commands/init.rs
@@ -59,7 +59,7 @@ pub fn init(repo: git::Repository, args: Args, profile: &profile::Profile) -> an
    let interactive = args.interactive();
    let visibility = args.visibility();
    let seed = args.seed();
-
    let should_announce = args.should_announce();
+
    let should_announce = args.announce();

    let default_branch = match find_default_branch(&repo) {
        Err(err @ DefaultBranchError::Head) => {
@@ -134,6 +134,15 @@ pub fn init(repo: git::Repository, args: Args, profile: &profile::Profile) -> an
        Visibility::from_str(selected)?
    };

+
    let should_announce = match should_announce {
+
        Some(announce) => announce,
+
        None if interactive.yes() => match visibility {
+
            Visibility::Public => term::ask("Announce to the public network now", false),
+
            Visibility::Private { .. } => false,
+
        },
+
        None => false,
+
    };
+

    let signer = term::signer(profile)?;
    let mut node = radicle::Node::new(profile.socket());
    let mut spinner = term::spinner("Initializing...");
@@ -144,7 +153,7 @@ pub fn init(repo: git::Repository, args: Args, profile: &profile::Profile) -> an
        name,
        &description,
        branch.clone(),
-
        visibility,
+
        visibility.clone(),
        &signer,
        &profile.storage,
    ) {
@@ -205,7 +214,7 @@ pub fn init(repo: git::Repository, args: Args, profile: &profile::Profile) -> an
            term::blank();

            // Announce inventory to network.
-
            if should_announce {
+
            if visibility.is_private() || (visibility.is_public() && should_announce) {
                if let Err(e) = announce(rid, doc, &mut node, &profile.config) {
                    term::blank();
                    term::warning(format!(
modified crates/radicle-cli/src/commands/init/args.rs
@@ -90,11 +90,12 @@ impl Args {
        !self.no_seed
    }

-
    pub(super) fn should_announce(&self) -> bool {
+
    pub(super) fn announce(&self) -> Option<bool> {
        match (self.announce, self.no_announce) {
-
            (false, true) | (false, false) => false,
-
            (true, false) => true,
-
            (true, true) => false,
+
            (false, false) => None,
+
            (false, true) => Some(false),
+
            (true, false) => Some(true),
+
            (true, true) => Some(false),
        }
    }
}