Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ uuid = { version = "1.16.0", features = ["serde", "v4"] }
version-compare = "0.2.0"
viuer = { version = "0.9.1", features = ["print-file"] }
tempfile = "3.19.1"
glob = "0.3.3"

[build-dependencies]
built = "0.7"
Expand Down
52 changes: 48 additions & 4 deletions src/cmd_app.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#[cfg(target_os = "linux")]
use glob::glob;
#[cfg(not(target_os = "linux"))]
use std::path::PathBuf;

use anyhow::Result;
use clap::Parser;

#[cfg(not(target_os = "linux"))]
const NOT_INSTALLED_ERROR: &str = r#"The Zoo Design Studio is not installed.
Please download it from https://zoo.dev/design-studio/download
If you do have the Design Studio installed already, we were
Expand All @@ -31,19 +32,48 @@
impl crate::cmd::Command for CmdApp {
async fn run(&self, ctx: &mut crate::context::Context) -> Result<()> {
let app_path = get_app_path()?;
let extra_args = get_extra_args()?;

writeln!(ctx.io.out, "Opening the Zoo Design Studio at {}", app_path.display())?;

std::process::Command::new(app_path).arg(&self.path).spawn()?;
std::process::Command::new(app_path)
.arg(&self.path)
.args(&extra_args)
.spawn()?;

Ok(())
}
}

#[cfg(target_os = "linux")]
/// Get the path to the application on linux.
/// Get the path to the application on linux, assuming .AppImage installation as
/// suggested at https://github.com/KittyCAD/modeling-app/blob/ac23d40e0bc756028d3933060c0c4377e7f6b6a3/INSTALL.md#linux.
// TODO: consider other install locations
fn get_app_path() -> Result<std::path::PathBuf> {
anyhow::bail!("We don't yet support Linux, but we are working on it!");
match dirs::home_dir() {
Some(home) => {
let path = home
.join("Applications")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely not trivial at this point, started thread at https://kittycadworkspace.slack.com/archives/C04KFV6NKL0/p1758222119353819

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess this could be a * too 🫠

.join("Zoo Design Studio-*-arm64-linux.AppImage");
for entry in glob(&path.to_string_lossy()).expect("Failed to read glob pattern") {

Check warning on line 58 in src/cmd_app.rs

View workflow job for this annotation

GitHub Actions / semgrep-oss/scan

panic-in-function-returning-result

expect or unwrap called in function returning a Result
match entry {
Ok(path) => return Ok(path),
Err(e) => println!("{:?}", e),
}
}
anyhow::bail!(NOT_INSTALLED_ERROR);
}
None => {
anyhow::bail!("Could not determine home directory");
}
}
}

#[cfg(target_os = "linux")]
/// Get the extra args for the application on linux.
fn get_extra_args() -> Result<Vec<String>> {
let args = vec!["--no-sandbox".into()];
Ok(args)
}

#[cfg(target_os = "macos")]
Expand All @@ -62,6 +92,13 @@
anyhow::bail!(NOT_INSTALLED_ERROR);
}

#[cfg(target_os = "macos")]
/// Get the extra args for the application on macos.
fn get_extra_args() -> Result<Vec<String>> {
let args = vec![];
Ok(args)
}

#[cfg(target_os = "windows")]
/// Get the path to the application on windows.
fn get_app_path() -> Result<std::path::PathBuf> {
Expand All @@ -77,3 +114,10 @@

anyhow::bail!(NOT_INSTALLED_ERROR);
}

#[cfg(target_os = "macos")]
/// Get the extra args for the application on windows.
fn get_extra_args() -> Result<Vec<String>> {
let args = vec![];
Ok(args)
}
Loading