Integrating cli in a project #3881
|
I want to make a tool for a project to ease things like building it, fetching dependencies, and making releases, and a few other things, my goal is so that our CI that is very complex will be simplified and basically be few calls to this tool instead of the many things we have going on. This is a multi-repository project and I would like to use gh as a way to give me ease access to some GitHub functionality. Should I code my tool in GO leveraging gh as a library? Is this a possibility? Or should I avoid this and instead do my tool in any language and simply call gh when needed? |
Replies: 3 comments 2 replies
|
Thanks for asking!
|
This comment was marked as low quality.
This comment was marked as low quality.
|
Do not import Recommended: shell out to
|
| Task | Approach |
|---|---|
| Local developer ergonomics | Wrap gh subprocess calls |
| CI release automation | GitHub API + App token |
| Complex repo queries | gh api graphql -f query=... from your tool |
Why this fits your goal
You want CI to call a few commands instead of sprawling YAML — a thin internal CLI that wraps gh (or the API) gives you that without maintaining a fork of gh as a library.
Start with subprocess calls; refactor hot paths to the API only if you hit performance or parsing limits.
Thanks for asking!
ghis not intended for use as a library -- it wouldn't work too well and it will break as releases come out. Calling out toghwhen needed is the way to go.