summaryrefslogtreecommitdiff
path: root/crates/typst-cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-cli/src')
-rw-r--r--crates/typst-cli/src/args.rs5
-rw-r--r--crates/typst-cli/src/world.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs
index cf8a2c6f..9648d8ef 100644
--- a/crates/typst-cli/src/args.rs
+++ b/crates/typst-cli/src/args.rs
@@ -217,6 +217,11 @@ pub struct SharedArgs {
/// Arguments related to storage of packages in the system
#[clap(flatten)]
pub package_storage_args: PackageStorageArgs,
+
+ /// Number of parallel jobs spawned during compilation,
+ /// defaults to number of CPUs.
+ #[clap(long, short)]
+ pub jobs: Option<usize>,
}
/// Arguments related to where packages are stored in the system.
diff --git a/crates/typst-cli/src/world.rs b/crates/typst-cli/src/world.rs
index 9748d9c5..8e8b305f 100644
--- a/crates/typst-cli/src/world.rs
+++ b/crates/typst-cli/src/world.rs
@@ -56,6 +56,11 @@ pub struct SystemWorld {
impl SystemWorld {
/// Create a new system world.
pub fn new(command: &SharedArgs) -> Result<Self, WorldCreationError> {
+ // Set up the thread pool.
+ if let Some(jobs) = command.jobs {
+ rayon::ThreadPoolBuilder::new().num_threads(jobs).build_global().ok();
+ }
+
// Resolve the system-global input path.
let input = match &command.input {
Input::Stdin => None,