From 77c00cee5fb21456f93e4ef20bfa222921347155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Mon, 22 Nov 2021 20:27:17 +0100 Subject: [PATCH] Do not output anything when no repos found --- src/lib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index af88949..db9665b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -631,13 +631,19 @@ pub fn run() { process::exit(1); } - let config = Config { - trees: vec![find_in_tree(path).unwrap()], - }; + let trees = vec![find_in_tree(path).unwrap()]; + if trees.iter().all(|t| match &t.repos { + None => false, + Some(r) => r.is_empty(), + }) { + print_warning("No repositories found"); + } else { + let config = Config { trees }; - let toml = toml::to_string(&config).unwrap(); + let toml = toml::to_string(&config).unwrap(); - print!("{}", toml); + print!("{}", toml); + } } cmd::SubCommand::Worktree(args) => { let dir = match std::env::current_dir() {