cli: Add `--verbose` flag to `init`

This commit is contained in:
Alexis Sellier 2023-03-06 12:16:30 +01:00
parent c8c44c884c
commit be5c9c9258
No known key found for this signature in database
4 changed files with 12 additions and 7 deletions

View File

@ -8,11 +8,6 @@ $ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" -
Initializing local 🌱 project in . Initializing local 🌱 project in .
✓ Project heartwood created ✓ Project heartwood created
{
"name": "heartwood",
"description": "Radicle Heartwood Protocol & Stack",
"defaultBranch": "master"
}
✓ Syncing inventory.. ✓ Syncing inventory..
✓ Announcing inventory.. ✓ Announcing inventory..

View File

@ -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-track $ rad init --name heartwood --description "Radicle Heartwood Protocol & Stack" --no-confirm --no-track -v
Initializing local 🌱 project in . Initializing local 🌱 project in .

View File

@ -35,6 +35,7 @@ Options
--setup-signing Setup the radicle key as a signing key for this repository --setup-signing Setup the radicle key as a signing key for this repository
--announce Announce the new project to the network --announce Announce the new project to the network
--no-confirm Don't ask for confirmation during setup --no-confirm Don't ask for confirmation during setup
--verbose, -v Verbose mode
--help Print help --help Print help
"#, "#,
}; };
@ -49,6 +50,7 @@ pub struct Options {
pub setup_signing: bool, pub setup_signing: bool,
pub set_upstream: bool, pub set_upstream: bool,
pub announce: bool, pub announce: bool,
pub verbose: bool,
pub track: bool, pub track: bool,
} }
@ -67,6 +69,7 @@ impl Args for Options {
let mut setup_signing = false; let mut setup_signing = false;
let mut announce = false; let mut announce = false;
let mut track = true; let mut track = true;
let mut verbose = false;
while let Some(arg) = parser.next()? { while let Some(arg) = parser.next()? {
match arg { match arg {
@ -117,6 +120,9 @@ impl Args for Options {
Long("no-track") => { Long("no-track") => {
track = false; track = false;
} }
Long("verbose") | Short('v') => {
verbose = true;
}
Long("help") => { Long("help") => {
return Err(Error::Help.into()); return Err(Error::Help.into());
} }
@ -138,6 +144,7 @@ impl Args for Options {
setup_signing, setup_signing,
announce, announce,
track, track,
verbose,
}, },
vec![], vec![],
)) ))
@ -222,7 +229,9 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
)); ));
spinner.finish(); spinner.finish();
term::blob(json::to_string_pretty(&proj)?); if options.verbose {
term::blob(json::to_string_pretty(&proj)?);
}
if options.set_upstream || git::branch_remote(&repo, proj.default_branch()).is_err() { if options.set_upstream || git::branch_remote(&repo, proj.default_branch()).is_err() {
// Setup eg. `master` -> `rad/master` // Setup eg. `master` -> `rad/master`

View File

@ -97,6 +97,7 @@ pub fn seed(dir: &Path) -> Context {
set_upstream: false, set_upstream: false,
announce: false, announce: false,
track: false, track: false,
verbose: false,
}, },
&profile, &profile,
) )