summaryrefslogtreecommitdiff
path: root/crates/typst-cli/src/init.rs
diff options
context:
space:
mode:
authorLuizAugustoPapa <112978478+LuizAugustoPapa@users.noreply.github.com>2024-06-06 14:22:54 -0300
committerGitHub <noreply@github.com>2024-06-06 17:22:54 +0000
commitcc3e9c86022c5ae5a82938b0b65e3d2dca93b1ed (patch)
tree9497e2e4a92fab3b2f3f757a613b75308f644819 /crates/typst-cli/src/init.rs
parent753213c40a7967e2e425ad63da52aaac31681780 (diff)
Add more environment control parameters to CLI (#4227)
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com> Co-authored-by: Tulio Martins <tulioml240@gmail.com> Co-authored-by: PepinhoJp <pepinho.jp@gmail.com>
Diffstat (limited to 'crates/typst-cli/src/init.rs')
-rw-r--r--crates/typst-cli/src/init.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/typst-cli/src/init.rs b/crates/typst-cli/src/init.rs
index b0446bd1..cb6b6627 100644
--- a/crates/typst-cli/src/init.rs
+++ b/crates/typst-cli/src/init.rs
@@ -10,9 +10,12 @@ use typst::syntax::package::{
};
use crate::args::InitCommand;
+use crate::package::PackageStorage;
/// Execute an initialization command.
pub fn init(command: &InitCommand) -> StrResult<()> {
+ let package_storage = PackageStorage::from_args(&command.package_storage_args);
+
// Parse the package specification. If the user didn't specify the version,
// we try to figure it out automatically by downloading the package index
// or searching the disk.
@@ -20,12 +23,12 @@ pub fn init(command: &InitCommand) -> StrResult<()> {
// Try to parse without version, but prefer the error message of the
// normal package spec parsing if it fails.
let spec: VersionlessPackageSpec = command.template.parse().map_err(|_| err)?;
- let version = crate::package::determine_latest_version(&spec)?;
+ let version = package_storage.determine_latest_version(&spec)?;
StrResult::Ok(spec.at(version))
})?;
// Find or download the package.
- let package_path = crate::package::prepare_package(&spec)?;
+ let package_path = package_storage.prepare_package(&spec)?;
// Parse the manifest.
let manifest = parse_manifest(&package_path)?;