mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-18 18:08:07 +03:00
Tidy up xtask
This commit is contained in:
parent
d194edc49f
commit
d3a333b873
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -1150,7 +1150,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive",
|
"clap_derive 3.2.25",
|
||||||
"clap_lex 0.2.4",
|
"clap_lex 0.2.4",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@ -1166,6 +1166,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc"
|
checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
|
"clap_derive 4.3.2",
|
||||||
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1194,6 +1196,18 @@ dependencies = [
|
|||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "4.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.4.1",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.18",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
@ -8843,6 +8857,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
|||||||
name = "xtask"
|
name = "xtask"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"clap 4.3.5",
|
"clap 4.3.5",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -6,7 +6,8 @@ publish = false
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "4.0"
|
anyhow = "1.0"
|
||||||
|
clap = {version = "4.0", features = ["derive"]}
|
||||||
theme = {path = "../theme"}
|
theme = {path = "../theme"}
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
/// Common utilities for Zed developers.
|
||||||
|
// For more information, see [matklad's repository README](https://github.com/matklad/cargo-xtask/)
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
#[command(propagate_version = true)]
|
||||||
|
pub struct Cli {
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub command: Commands,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Command to run.
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum Commands {
|
||||||
|
/// Builds theme types for interop with Typescript.
|
||||||
|
BuildThemeTypes {
|
||||||
|
#[clap(short, long, default_value = "schemas")]
|
||||||
|
out_dir: PathBuf,
|
||||||
|
#[clap(short, long, default_value = "theme.json")]
|
||||||
|
file_name: PathBuf,
|
||||||
|
},
|
||||||
|
}
|
@ -1,11 +1,29 @@
|
|||||||
mod cli;
|
mod cli;
|
||||||
|
|
||||||
use schemars::schema_for;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use clap::Parser;
|
||||||
|
use schemars::schema_for;
|
||||||
use theme::Theme;
|
use theme::Theme;
|
||||||
fn main() {
|
|
||||||
|
fn build_themes(mut out_dir: PathBuf, file_name: PathBuf) -> Result<()> {
|
||||||
let theme = schema_for!(Theme);
|
let theme = schema_for!(Theme);
|
||||||
let output = serde_json::to_string_pretty(&theme).unwrap();
|
let output = serde_json::to_string_pretty(&theme)?;
|
||||||
std::fs::create_dir("schemas").ok();
|
|
||||||
std::fs::write("schemas/theme.json", output).ok();
|
std::fs::create_dir(&out_dir)?;
|
||||||
|
|
||||||
|
let mut file_path = out_dir;
|
||||||
|
out_dir.push(file_name);
|
||||||
|
|
||||||
|
std::fs::write(file_path, output)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
let args = cli::Cli::parse();
|
||||||
|
match args.command {
|
||||||
|
cli::Commands::BuildThemeTypes { out_dir, file_name } => build_themes(out_dir, file_name),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user