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

Expose cmds as libraries #174

Open
jkylling opened this issue Sep 25, 2024 · 3 comments
Open

Expose cmds as libraries #174

jkylling opened this issue Sep 25, 2024 · 3 comments

Comments

@jkylling
Copy link

I'd like to use jrsonnet for generating Kubernetes manifests in a cargo project. The ideal workflow is to be able to run cargo run --bin generate-manifests to compile jsonnet files to YAML or JSON. Here generate-manifests would be a binary effectively doing

Command::new("jsonnet").args(["--multi", "generated", "main.jsonnet"]).spawn().unwrap().wait().unwrap()

Currently, this is only possible by installing the correct version of jrsonnet or some other jsonnet implementation in an earlier step. It would be convenient if the jrsonnet CLI interface and main function could be used as a library.

@JarvisCraft
Copy link
Collaborator

This functionality is already available via the APIs which are used by jrsonnet CLI, thus you can use them already. Just take a look at what jrsonnet CLI does in its implementation after parsing input.

@jkylling
Copy link
Author

jkylling commented Oct 1, 2024

What part of the jrsonnet CLI do you mean? I looked at https://github.com/CertainLach/jrsonnet/blob/a31a8ef0c0189f88ed32d84cb2dcae3b7d7861af/cmds/jrsonnet/src/main.rs which looks involved enough that I'm a bit hesitant to copy parts of it.

@bruno-delfino1995
Copy link
Contributor

It's not up-to-date with this library's latest version, but I have a bare minimum here. You can ignore the external variable injection and use only the state + context + resolver pieces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants