Repository: AmbientRun/Ambient
File: app/src/main.rs (Rust)

Code before:
                let manifest = load_manifest(&assets, &path).await?;
                ambient_build::migrate::toml::process(&manifest, path.fs_path.unwrap())
                    .await
                    .context("Failed to migrate pipelines")?;
            }
            AssetCommand::Import(opt) => match opt.path.extension() {
                Some(ext) => {
                    if ext == "wav" || ext == "mp3" || ext == "ogg" {
                        let convert = opt.convert_audio;
                        ambient_build::pipelines::import_audio(opt.path.clone(), convert)
                            .context("failed to import audio")?;
                    } else if ext == "fbx" || ext == "glb" || ext == "gltf" || ext == "obj" {
                        let collider_from_model = opt.collider_from_model;
                        ambient_build::pipelines::import_model(
                            opt.path.clone(),
                            collider_from_model,
                        )
                        .context("failed to import models")?;
                    } else if ext == "jpg" || ext == "png" || ext == "gif" || ext == "webp" {
                        // TODO: import textures API may change, so this is just a placeholder
                        todo!();
                    } else {
                        eprintln!("Unsupported file type");
                    }
                }
                None => eprintln!("Unknown file type"),
            },
        }

        return Ok(());
    }

    // If a project was specified, assume that assets need to be built
    let manifest = match project {
        Some(_) => Some(load_manifest(&assets, &project_path).await?),
        None => None,
    };

    let build_config = match (&project, &manifest, project_path.fs_path.clone()) {
        (Some(project), Some(manifest), Some(fs_path)) => Some(ambient_build::BuildConfiguration {
            physics: PhysicsKey.get(&assets),
            path: fs_path,
            manifest: manifest.clone(),
            optimize: project.release,
            clean_build: project.clean_build,
            build_wasm_only: project.build_wasm_only,
        }),
        _ => None,
    };

    let metadata = if let Some(manifest) = manifest.as_ref() {

Review comment (bug):
I think it would be better to fail and return an error, rather than just printing text and exiting with SUCCESS.

Something like `=> anyhow::bail!("Unknown file type")` etc.

Silent errors that proceed anyways can be very frustrating since you easily miss a single line in the terminal if the rest of the command proceeds.

Code after:
                let manifest = load_manifest(&assets, &path).await?;
                ambient_build::migrate::toml::process(&manifest, path.fs_path.unwrap())
                    .await
                    .context("Failed to migrate pipelines")?;
            }
            AssetCommand::Import(opt) => match opt.path.extension() {
                Some(ext) => {
                    if ext == "wav" || ext == "mp3" || ext == "ogg" {
                        let convert = opt.convert_audio;
                        ambient_build::pipelines::import_audio(opt.path.clone(), convert)
                            .context("failed to import audio")?;
                    } else if ext == "fbx" || ext == "glb" || ext == "gltf" || ext == "obj" {
                        let collider_from_model = opt.collider_from_model;
                        ambient_build::pipelines::import_model(
                            opt.path.clone(),
                            collider_from_model,
                        )
                        .context("failed to import models")?;
                    } else if ext == "jpg" || ext == "png" || ext == "gif" || ext == "webp" {
                        // TODO: import textures API may change, so this is just a placeholder
                        todo!();
                    } else {
                        bail!("Unsupported file type");
                    }
                }
                None => bail!("Unknown file type"),
            },
        }

        return Ok(());
    }

    // If a project was specified, assume that assets need to be built
    let manifest = match project {
        Some(_) => Some(load_manifest(&assets, &project_path).await?),
        None => None,
    };

    let build_config = match (&project, &manifest, project_path.fs_path.clone()) {
        (Some(project), Some(manifest), Some(fs_path)) => Some(ambient_build::BuildConfiguration {
            physics: PhysicsKey.get(&assets),
            path: fs_path,
            manifest: manifest.clone(),
            optimize: project.release,
            clean_build: project.clean_build,
            build_wasm_only: project.build_wasm_only,
        }),
        _ => None,
    };

    let metadata = if let Some(manifest) = manifest.as_ref() {