Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Apr 25, 2024
1 parent 1d5f2fc commit 45547be
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/cmd_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;

const NOT_INSTALLED_ERROR: &str = r#"The Zoo Modeling App is not installed.
Please download it from https://zoo.dev/modeling-app/download
If you do have the Modeling App installed already, we were
unable to find it in the standard locations. Please open
an issue at https://github.com/KittyCAD/cli/issues/new"#;

/// Open a directory or file in the Zoo Modeling App on your desktop.
///
/// If you do not have the app installed, you will be prompted to download it.
Expand Down Expand Up @@ -32,6 +38,13 @@ impl crate::cmd::Command for CmdApp {
}
}

#[cfg(target_os = "linux")]
/// Get the path to the application on linux.
fn get_app_path() -> Result<std::path::PathBuf> {
anyhow::bail!("We don't yet support Linux, but we are working on it!");
}

#[cfg(target_os = "macos")]
/// Get the path to the application on macOS.
fn get_app_path() -> Result<std::path::PathBuf> {
let paths_to_try = [
Expand All @@ -47,11 +60,24 @@ fn get_app_path() -> Result<std::path::PathBuf> {
}
}

anyhow::bail!(
r#"The Zoo Modeling App is not installed.
Please download it from https://zoo.dev/modeling-app/download
If you do have the Modeling App installed already, we were
unable to find it in the standard locations. Please open
an issue at https://github.com/KittyCAD/cli/issues/new"#
);
anyhow::bail!(NOT_INSTALLED_ERROR);
}

#[cfg(target_os = "windows")]
/// Get the path to the application on windows.
fn get_app_path() -> Result<std::path::PathBuf> {
let paths_to_try = [
PathBuf::from(r#"C:\Program Files\Zoo Modeling App\Zoo Modeling App.exe"#),
PathBuf::from(r#"C:\Program Files\KittyCAD Modeling\Zoo Modeling App.exe"#),
PathBuf::from(r#"C:\Program Files\Zoo Modeling\Zoo Modeling App.exe"#),
PathBuf::from(r#"C:\Program Files\Zoo\Zoo Modeling App.exe"#),
];

for path in paths_to_try.iter() {
if path.exists() {
return Ok(path.clone());
}
}

anyhow::bail!(NOT_INSTALLED_ERROR);
}

0 comments on commit 45547be

Please sign in to comment.