Remove wsl command line args on non-windows platforms (#37422)

Max Brunsfeld created

Release Notes:

- N/A

Change summary

crates/cli/src/main.rs | 15 +++++++++++++--
crates/zed/src/main.rs |  8 +++++++-
2 files changed, 20 insertions(+), 3 deletions(-)

Detailed changes

crates/cli/src/main.rs 🔗

@@ -93,6 +93,7 @@ struct Args {
     /// Example: `me@Ubuntu` or `Ubuntu`.
     ///
     /// WARN: You should not fill in this field by hand.
+    #[cfg(target_os = "windows")]
     #[arg(long, value_name = "USER@DISTRO")]
     wsl: Option<String>,
     /// Not supported in Zed CLI, only supported on Zed binary
@@ -303,6 +304,11 @@ fn main() -> Result<()> {
         ]);
     }
 
+    #[cfg(target_os = "windows")]
+    let wsl = args.wsl.as_ref();
+    #[cfg(not(target_os = "windows"))]
+    let wsl = None;
+
     for path in args.paths_with_position.iter() {
         if path.starts_with("zed://")
             || path.starts_with("http://")
@@ -321,7 +327,7 @@ fn main() -> Result<()> {
             paths.push(tmp_file.path().to_string_lossy().to_string());
             let (tmp_file, _) = tmp_file.keep()?;
             anonymous_fd_tmp_files.push((file, tmp_file));
-        } else if let Some(wsl) = &args.wsl {
+        } else if let Some(wsl) = wsl {
             urls.push(format!("file://{}", parse_path_in_wsl(path, wsl)?));
         } else {
             paths.push(parse_path_with_position(path)?);
@@ -340,11 +346,16 @@ fn main() -> Result<()> {
             let (_, handshake) = server.accept().context("Handshake after Zed spawn")?;
             let (tx, rx) = (handshake.requests, handshake.responses);
 
+            #[cfg(target_os = "windows")]
+            let wsl = args.wsl;
+            #[cfg(not(target_os = "windows"))]
+            let wsl = None;
+
             tx.send(CliRequest::Open {
                 paths,
                 urls,
                 diff_paths,
-                wsl: args.wsl,
+                wsl,
                 wait: args.wait,
                 open_new_workspace,
                 env,

crates/zed/src/main.rs 🔗

@@ -707,11 +707,16 @@ pub fn main() {
             .map(|chunk| [chunk[0].clone(), chunk[1].clone()])
             .collect();
 
+        #[cfg(target_os = "windows")]
+        let wsl = args.wsl;
+        #[cfg(not(target_os = "windows"))]
+        let wsl = None;
+
         if !urls.is_empty() || !diff_paths.is_empty() {
             open_listener.open(RawOpenRequest {
                 urls,
                 diff_paths,
-                wsl: args.wsl,
+                wsl,
             })
         }
 
@@ -1192,6 +1197,7 @@ struct Args {
     /// Example: `me@Ubuntu` or `Ubuntu`.
     ///
     /// WARN: You should not fill in this field by hand.
+    #[cfg(target_os = "windows")]
     #[arg(long, value_name = "USER@DISTRO")]
     wsl: Option<String>,