đź—ť
summary refs log tree commit diff
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
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
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--LICENSE25
-rw-r--r--src/main.rs14
4 files changed, 28 insertions, 15 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2209fa6..bf6abc8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -43,7 +43,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "cgit-syntect"
-version = "0.1.0"
+version = "0.1.1"
 dependencies = [
  "syntect",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index 928f8ba..3bee23e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "cgit-syntect"
-version = "0.1.0"
+version = "0.1.1"
 edition = "2021"
 
 [dependencies]
diff --git a/LICENSE b/LICENSE
index f875bc5..b27a5bb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,13 +1,18 @@
 Copyright 2024 mia
 
-Permission to use, copy, modify, and/or distribute this software for any purpose
-with or without fee is hereby granted, provided that the above copyright notice
-and this permission notice appear in all copies.
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the “Software”), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
 
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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();