just playing with tangled

add new builtin formats

+25 -2
+5
cli/src/complete.rs
··· 496 496 /// can't tell which these are. So, this not reliable, but probably good enough 497 497 /// for command-line completion. 498 498 pub fn diff_editors() -> Vec<CompletionCandidate> { 499 + let builtin_format_kinds: Vec<String> = crate::diff_util::BuiltinFormatKind::ALL_VARIANTS 500 + .iter() 501 + .map(|kind| format!(":{}", kind.to_arg_name())) 502 + .collect(); 499 503 with_jj(|_, settings| { 500 504 Ok(std::iter::once(":builtin") 505 + .chain(builtin_format_kinds.iter().map(|s| s.as_str())) 501 506 .chain(configured_merge_tools(settings)) 502 507 .map(CompletionCandidate::new) 503 508 .collect())
+14 -2
cli/src/diff_util.rs
··· 156 156 } 157 157 158 158 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 159 - enum BuiltinFormatKind { 159 + pub enum BuiltinFormatKind { 160 160 Summary, 161 161 Stat, 162 162 Types, ··· 166 166 } 167 167 168 168 impl BuiltinFormatKind { 169 + // Alternatively, we could use or vendor one of the crates `strum`, 170 + // `enum-iterator`, or `variant_count` (for a check that the length of the array 171 + // is correct). The latter is very simple and is also a nightly feature. 172 + pub const ALL_VARIANTS: &[BuiltinFormatKind] = &[ 173 + Self::Summary, 174 + Self::Stat, 175 + Self::Types, 176 + Self::NameOnly, 177 + Self::Git, 178 + Self::ColorWords, 179 + ]; 180 + 169 181 fn from_name(name: &str) -> Result<Self, String> { 170 182 match name { 171 183 "summary" => Ok(Self::Summary), ··· 209 221 } 210 222 } 211 223 212 - fn to_arg_name(self) -> &'static str { 224 + pub fn to_arg_name(self) -> &'static str { 213 225 match self { 214 226 Self::Summary => "summary", 215 227 Self::Stat => "stat",
+6
cli/tests/test_completion.rs
··· 1114 1114 let output = test_env.run_jj_in(dir, ["--", "jj", "diffedit", "--tool", ""]); 1115 1115 insta::assert_snapshot!(output, @r" 1116 1116 :builtin 1117 + :summary 1118 + :stat 1119 + :types 1120 + :name-only 1121 + :git 1122 + :color-words 1117 1123 diffedit3 1118 1124 diffedit3-ssh 1119 1125 difft