mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
theme_importer: Add --output
flag for outputting the theme to a file (#7486)
```bash cargo run -p theme_importer -- dark-plus-syntax-color-theme.json --output output.json ``` Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
e6dad23154
commit
45cf36e870
@ -1 +1,5 @@
|
|||||||
# Zed Theme Importer
|
# Zed Theme Importer
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo run -p theme_importer -- dark-plus-syntax-color-theme.json --output output-theme.json
|
||||||
|
```
|
||||||
|
@ -4,6 +4,7 @@ mod util;
|
|||||||
mod vscode;
|
mod vscode;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
@ -75,6 +76,10 @@ struct Args {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
warn_on_missing: bool,
|
warn_on_missing: bool,
|
||||||
|
|
||||||
|
/// The path to write the output to.
|
||||||
|
#[arg(long, short)]
|
||||||
|
output: Option<PathBuf>,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<Command>,
|
command: Option<Command>,
|
||||||
}
|
}
|
||||||
@ -146,7 +151,12 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let theme_json = serde_json::to_string_pretty(&theme).unwrap();
|
let theme_json = serde_json::to_string_pretty(&theme).unwrap();
|
||||||
|
|
||||||
println!("{}", theme_json);
|
if let Some(output) = args.output {
|
||||||
|
let mut file = File::create(output)?;
|
||||||
|
file.write_all(theme_json.as_bytes())?;
|
||||||
|
} else {
|
||||||
|
println!("{}", theme_json);
|
||||||
|
}
|
||||||
|
|
||||||
log::info!("Done!");
|
log::info!("Done!");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user