xchecker_runner/claude/
wsl.rs1use crate::command_spec::CommandSpec;
2use std::env;
3
4use super::exec::Runner;
5
6impl Runner {
7 #[must_use]
9 pub fn get_wsl_distro_name(&self) -> Option<String> {
10 if let Some(distro) = &self.wsl_options.distro {
12 return Some(distro.clone());
13 }
14
15 if let Ok(distro_name) = env::var("WSL_DISTRO_NAME")
17 && !distro_name.is_empty()
18 {
19 return Some(distro_name);
20 }
21
22 if let Ok(output) = CommandSpec::new("wsl")
24 .args(["-l", "-q"])
25 .to_command()
26 .output()
27 && output.status.success()
28 {
29 let distros = String::from_utf8_lossy(&output.stdout);
30 for line in distros.lines() {
32 let line = line.trim();
33 if !line.is_empty() {
34 return Some(line.to_string());
35 }
36 }
37 }
38
39 None
40 }
41
42 pub(super) fn wsl_command_spec(&self, args: &[String]) -> CommandSpec {
43 let claude_path = self.wsl_options.claude_path.as_deref().unwrap_or("claude");
45
46 let mut spec = CommandSpec::new("wsl");
49
50 if let Some(distro) = &self.wsl_options.distro {
52 spec = spec.args(["-d", distro]);
53 }
54
55 spec.arg("--exec").arg(claude_path).args(args)
56 }
57}