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

huangapple go评论75阅读模式
英文:

Link another Golang Cobra CLI to current Golang Cobra CLI

问题

我正在开发一个新的 Golang Cobra CLI,它处理多个命令。后来我发现已经有一个现有的 Golang Cobra CLI,它处理了一些我将在新的 CLI 中涵盖的命令,但不是全部。换句话说,我的新 CLI 包含了现有 CLI 的所有命令,并添加了一些额外的命令。

我们是否可以将现有的 CLI 链接到新的 CLI 中?

注意:我不确定“链接”是否是描述我感兴趣的操作的最佳词语。如果这个问题在 SA 上已经有答案,请标记为重复。

英文:

I am working on a new Golang Cobra CLI, which handles several commands. 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. In other words, my new CLI cover all commands of the existing CLI with some extra commands.

Is it possible for us to link the existing CLI into the new 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.

答案1

得分: 1

我认为你最好的选择是使用较少命令的方式fork另一个仓库,然后编辑它以添加你的命令。假设这两个仓库都是开源的。

如果你的代码是闭源的,那么你可以将他们的仓库作为一个依赖引入。

英文:

I think your best bet is to fork the other repo with fewer commands, then edit it to add your commands. Assuming that both repos are open source.

If your code is closed-source then you can bring in their repo as a dependency.

huangapple
  • 本文由 发表于 2022年2月25日 11:56:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/71260882.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定