🗝
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authormia <mia@mia.jetzt>2024-06-03 20:24:35 -0700
committermia <mia@mia.jetzt>2024-06-03 20:24:35 -0700
commit40509ba913e52196b2dd7f3a733bec816d38bda0 (patch)
treed96d730a1b5f7b612df4b214b638508c48fc531c /src
parent2c3f80a526d98a0aaced266e96c7cbb9668bc44d (diff)
downloadcgit-syntect-0.1.1.tar.gz
cgit-syntect-0.1.1.zip
allow passing theme data in by stdin v0.1.1
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files changed, 11 insertions, 3 deletions
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();