Skip to content

Add input-file CLI argument and sys.input-files variable - #6073

Closed
jmpunkt wants to merge 1 commit into
typst:mainfrom
jmpunkt:add-input-files
Closed

jmpunkt wants to merge 1 commit into
typst:mainfrom
jmpunkt:add-input-files

Conversation

@jmpunkt

@jmpunkt jmpunkt commented Mar 18, 2025

Copy link
Copy Markdown

Details

Implementation

I followed the existing inputs implementation. However, there are no tests, so I put a manual test below.

One thing I noticed, is the missing file path resolution in the Fish shell (works for Bash). For example, when writing

typst c --input-file el=~/test.el test.typ

and the file exists, then we can not resolve that path. std::fs::canonicalize does not resolve ~ for us. The command fails with the error code: ~/test.el does not exist. As a result, Fish users will get this rather unexpected error. Might also be a bug in the Fish shell so I am not sure.

Manual Test

test.typ

#raw(str(sys.input-files.el), lang: "lisp")

test.el

(message "hi")
typst c --input-file el=./test.el test.typ

@laurmaedje laurmaedje added interface PRs that add to or change Typst's user-facing interface as opposed to internals or docs changes. cli About Typst's command line interface. labels Mar 24, 2025
@laurmaedje

Copy link
Copy Markdown
Member

We've discussed this among the team and came to the conclusion that we can imagine something like this in principle, but would like to see a more general solution.

One idea would be something along the lines of an --input-path mechanism that adds instances of a to-be-added path type to sys.inputs and then one can read from those paths. This would allow using this mechanism not just for bytes, but also for importing/including and to read from whole directories. For now, this is blocked on the addition of a path type though.

Thank you still for the PR!

@laurmaedje laurmaedje closed this Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli About Typst's command line interface. interface PRs that add to or change Typst's user-facing interface as opposed to internals or docs changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants