From 8c7a7ca2f538fd9240906f6eb746e55d75a6f4fd Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 6 Aug 2025 13:13:57 +0100 Subject: feat(init): use user grasp list for defaults instead of relying on hardcoded grasp server options. couldn't we look up those selected for other repos for the user instead? --- src/bin/ngit/sub_commands/init.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/bin/ngit/sub_commands/init.rs') diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 01fcaea..6f3a357 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -265,12 +265,24 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { &identifier, ); let mut selections: Vec = vec![true; options.len()]; // Initialize selections based on existing options + let empty = options.is_empty(); + for user_grasp_option in user_ref.grasp_list.urls { + // Check if any option contains the user_grasp_option as a substring + if !options + .iter() + .any(|option| option.contains(user_grasp_option.as_str())) + { + options.push(user_grasp_option.to_string()); // Add if not found + selections.push(empty); // mark as selected if no existing grasp otherwise not + } + } + let empty = options.is_empty(); for fallback in fallback_grasp_servers { // Check if any option contains the fallback as a substring if !options.iter().any(|option| option.contains(fallback)) { options.push(fallback.clone()); // Add fallback if not found - selections.push(empty); // mark as selected if no existing ngit relay otherwise not + selections.push(empty); // mark as selected if no existing selections otherwise not } } let selected = multi_select_with_custom_value( -- cgit v1.2.3