cli: Track projects we initialize
This commit is contained in:
parent
5f4c6edee4
commit
27d0c8f235
|
|
@ -3,7 +3,7 @@ To create your first radicle project, navigate to a git repository, and run
|
||||||
the `init` command:
|
the `init` command:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm --no-sync
|
$ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm --no-sync --no-track
|
||||||
|
|
||||||
Initializing local 🌱 project in .
|
Initializing local 🌱 project in .
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ pub struct Options {
|
||||||
pub setup_signing: bool,
|
pub setup_signing: bool,
|
||||||
pub set_upstream: bool,
|
pub set_upstream: bool,
|
||||||
pub sync: bool,
|
pub sync: bool,
|
||||||
|
pub track: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args for Options {
|
impl Args for Options {
|
||||||
|
|
@ -65,6 +66,7 @@ impl Args for Options {
|
||||||
let mut set_upstream = false;
|
let mut set_upstream = false;
|
||||||
let mut setup_signing = false;
|
let mut setup_signing = false;
|
||||||
let mut sync = true;
|
let mut sync = true;
|
||||||
|
let mut track = true;
|
||||||
|
|
||||||
while let Some(arg) = parser.next()? {
|
while let Some(arg) = parser.next()? {
|
||||||
match arg {
|
match arg {
|
||||||
|
|
@ -115,6 +117,9 @@ impl Args for Options {
|
||||||
Long("no-sync") => {
|
Long("no-sync") => {
|
||||||
sync = false;
|
sync = false;
|
||||||
}
|
}
|
||||||
|
Long("no-track") => {
|
||||||
|
track = false;
|
||||||
|
}
|
||||||
Long("help") => {
|
Long("help") => {
|
||||||
return Err(Error::Help.into());
|
return Err(Error::Help.into());
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +140,7 @@ impl Args for Options {
|
||||||
set_upstream,
|
set_upstream,
|
||||||
setup_signing,
|
setup_signing,
|
||||||
sync,
|
sync,
|
||||||
|
track,
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
))
|
))
|
||||||
|
|
@ -193,6 +199,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||||
let branch = RefString::try_from(branch.clone())
|
let branch = RefString::try_from(branch.clone())
|
||||||
.map_err(|e| anyhow!("invalid branch name {:?}: {}", branch, e))?;
|
.map_err(|e| anyhow!("invalid branch name {:?}: {}", branch, e))?;
|
||||||
|
|
||||||
|
let mut node = radicle::Node::new(profile.socket());
|
||||||
let mut spinner = term::spinner("Initializing...");
|
let mut spinner = term::spinner("Initializing...");
|
||||||
|
|
||||||
match radicle::rad::init(
|
match radicle::rad::init(
|
||||||
|
|
@ -206,6 +213,12 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||||
Ok((id, doc, _)) => {
|
Ok((id, doc, _)) => {
|
||||||
let proj = doc.project()?;
|
let proj = doc.project()?;
|
||||||
|
|
||||||
|
if options.track {
|
||||||
|
// 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)?;
|
||||||
|
}
|
||||||
|
|
||||||
spinner.message(format!(
|
spinner.message(format!(
|
||||||
"Project {} created",
|
"Project {} created",
|
||||||
term::format::highlight(proj.name())
|
term::format::highlight(proj.name())
|
||||||
|
|
@ -230,7 +243,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||||
}
|
}
|
||||||
if options.sync {
|
if options.sync {
|
||||||
let spinner = term::spinner("Announcing refs..");
|
let spinner = term::spinner("Announcing refs..");
|
||||||
if let Err(e) = radicle::Node::new(profile.socket()).announce_refs(id) {
|
if let Err(e) = node.announce_refs(id) {
|
||||||
spinner.error(e);
|
spinner.error(e);
|
||||||
} else {
|
} else {
|
||||||
spinner.finish();
|
spinner.finish();
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ pub fn seed(dir: &Path) -> Context {
|
||||||
setup_signing: false,
|
setup_signing: false,
|
||||||
set_upstream: false,
|
set_upstream: false,
|
||||||
sync: false,
|
sync: false,
|
||||||
|
track: false,
|
||||||
},
|
},
|
||||||
&profile,
|
&profile,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue