简体   繁体   English

将另一个 Golang Cobra CLI 链接到当前的 Golang Cobra CLI

[英]Link another Golang Cobra CLI to current Golang Cobra CLI

I am working on a new Golang Cobra CLI, which handles several commands.我正在开发一个新的 Golang Cobra CLI,它可以处理多个命令。 I later on found out that there is already an existing Golang Cobra CLI that handles some commands that I will be covering in the new CLI, but not all.后来我发现已经有一个现有的 Golang Cobra CLI 可以处理我将在新 CLI 中介绍的一些命令,但不是全部。 In other words, my new CLI cover all commands of the existing CLI with some extra commands.换句话说,我的新 CLI 涵盖了现有 CLI 的所有命令以及一些额外的命令。

Is it possible for us to link the existing CLI into the new CLI?我们是否可以将现有的 CLI 链接到新的 CLI 中?

Note: I am not sure whether "link" is the best word to describe what I am interested to do.注意:我不确定“链接”是否是描述我感兴趣的事情的最佳词。 In case this is already answered before on SA, feel free to mark this as duplicate.如果这已经在 SA 上回答过,请随时将其标记为重复。

I think your best bet is to fork the other repo with fewer commands, then edit it to add your commands.我认为你最好的选择是用更少的命令分叉另一个 repo,然后编辑它以添加你的命令。 Assuming that both repos are open source.假设这两个回购都是开源的。

If your code is closed-source then you can bring in their repo as a dependency.如果您的代码是封闭源代码,那么您可以将其存储库作为依赖项引入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM