Seeking advice for building a Rust CLI wrapper

Hello,

I just started learning Rust, and I am currently trying to build a CLI wrapper for an existing Rust workspace on GitHub.

The purpose of the CLI wrapper is to abstract the CLI commands for two binary packages within the workspace (i.e., the two binary packages are CLI applications themselves). Essentially, the CLI wrapper serves as a higher-level generic interface for running the commands.

Questions:

  • Where should I create my CLI wrapper? Should it be created in the same workspace, or should it be outside?

I plan to use the “Clap” library for parsing the CLI arguments from the wrapper, but I am not sure what’s the best way for me to integrate the binary workspace packages.

Any help or advice would be sincerely appreciated.

Kevin

Well, given the crates have public functions, you can always import them as libraries and use them directly from your CLI. Otherwise, you'd have to spawn a command process, passing in the appropriate arguments to it.

1 Like

Thanks for your response. I don't know if I can import them as libraries given they are both binary crates. However, I will look into spawning them as a separate command process.

Thank you,
Kevin

Responding to OPs original question.

I decided to create the cli-wrapper package within the workspace (along with the other members).

This makes sense to me because now I can directly call or spawn the binary CLI crates within the relative workspace (using the cli-wrapper). Additionally, I can potentially use some of the existing libraries in the workspace, or write a new one that can be leveraged for the CLI applications themselves (promoting code reusability)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.