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 diesel_cli's functionality as a library #357

Open
jimmycuadra opened this Issue Jun 16, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@jimmycuadra
Contributor

jimmycuadra commented Jun 16, 2016

Would it be possible to expose the functionality of diesel_cli as a Rust library? I'd like to be able to programmatically perform diesel database setup from Rust without shelling out.

@sgrif

This comment has been minimized.

Member

sgrif commented Jun 17, 2016

It would probably make sense for CLI to expose a reasonable public API there. /cc @mcasper

@travismiller

This comment has been minimized.

travismiller commented Jul 16, 2018

Would something like this work?

This PoC just exposes a run function where you can send arguments directly to the Clap Application.

// diesel database setup
diesel_cli::run(vec!["database", "setup"]);

The crux of this uses https://docs.rs/clap/2.32.0/clap/struct.App.html#method.get_matches_from

It probably makes more sense to use https://docs.rs/clap/2.32.0/clap/struct.App.html#method.get_matches_from_safe so that an API user could handle a result.

@sgrif

This comment has been minimized.

Member

sgrif commented Jul 17, 2018

That would certainly be the easiest to implement, but I'd rather just have a more static API akin to libgit2 vs git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment