Files
zed/tooling/xtask/src/workspace.rs
Marshall Bowers b01878aadf Add xtask for finding crates with missing licenses (#11776)
This PR adds a new `cargo xtask licenses` command for finding crates
with missing license files.

A number of crates were uncovered that were missing a license file, and
have had the appropriate license file added.

Release Notes:

- N/A
2024-05-13 18:52:12 -04:00

18 lines
486 B
Rust

use std::fs;
use anyhow::{anyhow, Result};
use cargo_toml::{Manifest, Workspace};
use toml;
/// Returns the Cargo workspace.
pub fn load_workspace() -> Result<Workspace> {
let workspace_cargo_toml = fs::read_to_string("Cargo.toml")?;
let workspace_cargo_toml: Manifest = toml::from_str(&workspace_cargo_toml)?;
let workspace = workspace_cargo_toml
.workspace
.ok_or_else(|| anyhow!("top-level Cargo.toml is not a Cargo workspace"))?;
Ok(workspace)
}