From 40509ba913e52196b2dd7f3a733bec816d38bda0 Mon Sep 17 00:00:00 2001 From: mia Date: Mon, 3 Jun 2024 20:24:35 -0700 Subject: allow passing theme data in by stdin --- src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 9cc7b85..734dfd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::{ - io::{stdout, BufWriter, Write}, + io::{stdout, BufWriter, Cursor, Read, Write}, path::PathBuf, str::FromStr, }; @@ -34,11 +34,19 @@ fn compile() { fn theme() { let mut args = std::env::args(); args.next(); // arg0 - let input: PathBuf = args.next().unwrap().into(); + let input = args.next().unwrap(); let css_path: PathBuf = args.next().unwrap().into(); let scopes_path: PathBuf = args.next().unwrap().into(); - let theme = ThemeSet::get_theme(input).unwrap(); + let theme = { + if input == "-" { + let mut buffer = Vec::new(); + std::io::stdin().read_to_end(&mut buffer).unwrap(); + ThemeSet::load_from_reader(&mut Cursor::new(buffer)).unwrap() + } else { + ThemeSet::get_theme(input).unwrap() + } + }; let mut css_gen = Vec::new(); let mut scopes_gen = Vec::new(); -- cgit 1.4.1