From 50a97d9add1f436e36cc58cf7ef6e2789b4826c8 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Fri, 9 Jun 2023 13:36:21 +0200 Subject: [PATCH] cli: Add `--scope` flag to `rad init` Defaults to `all`. --- radicle-cli/examples/rad-init-sync.md | 2 +- radicle-cli/src/commands/init.rs | 29 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/radicle-cli/examples/rad-init-sync.md b/radicle-cli/examples/rad-init-sync.md index 88dd1c41..256873d0 100644 --- a/radicle-cli/examples/rad-init-sync.md +++ b/radicle-cli/examples/rad-init-sync.md @@ -3,7 +3,7 @@ To create your first radicle project, navigate to a git repository, and run the `init` command: ``` -$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm --announce +$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm --announce --scope trusted Initializing radicle 👾 project in . diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index 51b38b40..a38d53b7 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -29,15 +29,16 @@ Usage Options - --name Name of the project - --description Description of the project - --default-branch The default branch of the project - -u, --set-upstream Setup the upstream of the default branch - --setup-signing Setup the radicle key as a signing key for this repository - --announce Announce the new project to the network - --no-confirm Don't ask for confirmation during setup - -v, --verbose Verbose mode - --help Print help + --name Name of the project + --description Description of the project + --default-branch The default branch of the project + --scope Tracking scope (default: all) + -u, --set-upstream Setup the upstream of the default branch + --setup-signing Setup the radicle key as a signing key for this repository + --announce Announce the new project to the network + --no-confirm Don't ask for confirmation during setup + -v, --verbose Verbose mode + --help Print help "#, }; @@ -49,6 +50,7 @@ pub struct Options { pub branch: Option, pub interactive: Interactive, pub setup_signing: bool, + pub scope: Scope, pub set_upstream: bool, pub announce: bool, pub verbose: bool, @@ -69,6 +71,7 @@ impl Args for Options { let mut set_upstream = false; let mut setup_signing = false; let mut announce = false; + let mut scope = Scope::All; let mut track = true; let mut verbose = false; @@ -106,6 +109,11 @@ impl Args for Options { branch = Some(value); } + Long("scope") => { + let value = parser.value()?; + + scope = term::args::parse_value("scope", value)?; + } Long("set-upstream") | Short('u') => { set_upstream = true; } @@ -140,6 +148,7 @@ impl Args for Options { name, description, branch, + scope, interactive, set_upstream, setup_signing, @@ -222,7 +231,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> if options.track && node.is_running() { // It's important to track our own repositories to make sure that our node signals // interest for them. This ensures that messages relating to them are relayed to us. - node.track_repo(id, Scope::default())?; + node.track_repo(id, options.scope)?; } spinner.message(format!(