From 8300f75f22cb4dd1b871a7e617397ff7d56ba001 Mon Sep 17 00:00:00 2001 From: Michael Lohr Date: Wed, 12 Apr 2023 19:03:12 +0200 Subject: [PATCH] Read font path from environment variables (#649) --- README.md | 3 +++ cli/Cargo.toml | 2 +- cli/src/args.rs | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e1091653a..978208676 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,9 @@ typst --font-path path/to/fonts compile file.typ # Lists all of the discovered fonts in the system and the given directory. typst --font-path path/to/fonts fonts + +# Or via environement variable (Linux syntax). +TYPST_FONT_PATHS=path/to/fonts typst fonts ``` If you prefer an integrated IDE-like experience with autocompletion and instant diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 68e50bb30..853579226 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -32,7 +32,7 @@ once_cell = "1" same-file = "1" siphasher = "0.3" walkdir = "2" -clap = { version = "4.2.1", features = ["derive"] } +clap = { version = "4.2.1", features = ["derive", "env"] } open = "4.0.1" [build-dependencies] diff --git a/cli/src/args.rs b/cli/src/args.rs index c88c9a21b..42d52140f 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -7,11 +7,11 @@ use clap::{ArgAction, Parser, Subcommand}; #[clap(name = "typst", version = crate::typst_version(), author)] pub struct CliArguments { /// Add additional directories to search for fonts - #[clap(long = "font-path", value_name = "DIR", action = ArgAction::Append)] + #[clap(long = "font-path", env = "TYPST_FONT_PATHS", value_name = "DIR", action = ArgAction::Append)] pub font_paths: Vec, /// Configure the root for absolute paths - #[clap(long = "root", value_name = "DIR")] + #[clap(long = "root", env = "TYPST_ROOT", value_name = "DIR")] pub root: Option, /// The typst command to run