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

Librarification #95

Open
blyxxyz opened this issue Mar 9, 2021 · 1 comment
Open

Librarification #95

blyxxyz opened this issue Mar 9, 2021 · 1 comment

Comments

@blyxxyz
Copy link
Collaborator

blyxxyz commented Mar 9, 2021

It would be nice to expose a library interface, to enable projects to build on top of xh along the lines of http-prompt. It would also help with #88.

This could be a pretty big change. We'd have to decide what to expose and commit to not breaking compatibility. Refactoring would become harder the more we expose.

Some concrete steps would be:

  • Move most things out of main
  • Change instances of pub to pub(crate)
  • Add top-level re-exports
  • (Maybe) add #[non_exhaustive] to certain public enums
  • (Maybe) use custom error types instead of anyhow

It could help to have a consuming project that lives in the same repository (in a workspace).

At first glance, we might not have to expose that much, see how http-prompt calls it. But I haven't looked at other projects, and a richer API might be a lot more convenient.

Breaking the public interface after 1.0 would mean incrementing the major version number. I can think of a few approaches:

  • Get this in place before a 1.0 release and be very careful to provide something we can remain compatible with.
  • Be willing to increment the major version number even when nothing breaks for normal users of the tool.
  • Move most of the code into a new package (e.g. xh_core) that can increment its major version freely, while the xh package becomes a wrapper around it with more conservative versioning.
@satvikpendem
Copy link

Coming from #289, to be honest I didn't realize you were already using reqwest underneath. I liked the single line of xh :8080 rather than the multiline usage of reqwest, but it's likely not enough of a big deal to need to librarify xh.

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

2 participants