Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow typst watch --open to specify a command with arguments #4654

Closed
jason-s opened this issue Aug 1, 2024 · 4 comments
Closed

Allow typst watch --open to specify a command with arguments #4654

jason-s opened this issue Aug 1, 2024 · 4 comments
Labels
feature request New feature or request

Comments

@jason-s
Copy link

jason-s commented Aug 1, 2024

Description

I would like Typst to run a Python script whenever a compilation completes. But right now typst watch --open only allows the name of a command (without arguments) to run.

Use Case

Give users more freedom to run an arbitrary command

@jason-s jason-s added the feature request New feature or request label Aug 1, 2024
@Andrew15-5
Copy link
Contributor

You can make your script executable and pass in the "$(realpath script.py)" or wrap it in shell script file for extra arguments:

#/bin/sh
exec python3 script.py arg1 arg2
# exec ./script.py arg1 arg2 # I don't remember if you need `./` here.

and then pass this script file instead.

I think adding support for arguments would be nice, but you can live without it just fine as I showed you. Plus passing multiple arguments to a single flag is very hard. It becomes super messy when quotes and escaping comes into play. There are very few CLIs that do this (find -exec cmd arg1 arg2 \;).

I haven't tested any of that, but it all should work.

@jason-s
Copy link
Author

jason-s commented Aug 1, 2024

I can't do either. Windows doesn't support #/bin/sh, and I don't have enough familiarity with a C compiler to create a special executable to do what I want, which seems like overkill.

I have a workaround for now (wrote a script to check the file mod time of the .pdf file), but I do think there should be a way to pass in arguments.

Plus passing multiple arguments to a single flag is very hard. It becomes super messy when quotes and escaping comes into play.

Understood. I'm not looking to pass in arbitrary commands; I can handle the specialization with my script. But at least it should be possible to specify python myscript.py or java -jar blahblah.jar or whatever.

@Andrew15-5
Copy link
Contributor

Windows doesn't support #/bin/sh

I don't like shindows, but I'm pretty sure you can do something similar with a .bat file or something. But I wouldn't be surprised if it just doesn't have any alternative at all.

@laurmaedje
Copy link
Member

--open only runs once, so it wouldn't really work anyway, if I'm understanding the requirement correctly. But I think watching the PDF file is a good solution, so I don't think this warrants a new argument.

@laurmaedje laurmaedje closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants