-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
pkg/cmd
not cmd
for Cobra commands
- Loading branch information
Showing
4 changed files
with
21 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Use `pkg/cmd` not `cmd` for Cobra commands | ||
|
||
Everyone---except Cobra---agrees that the `cmd` directory is to contain subdirectories that have `main` packages, you know, *commands* in them. That's the whole fucking point of `cmd`. Cobra decides to ignore this best practice and do whatever the fuck even though it never had to do that. In the process is also forces the creation of unnecessary stuttering (ex: `cmd.AddCmd`) and creating a bunch of completely importable subcommand trees that cannot be combined into other monoliths with an easy import just because it was not initially designed that way. | ||
|
||
Well, there's no fucking requirement to do it that way. In fact, one of the best command line tools ever created, the GitHub `gh` tool, decided to ignore Cobra's shitty initializer command and put everything in `pkg/cmd` instead. Thank God a big project has the courage to tell `cobra-cli` to go fuck itself and do the right thing. Unfortunately, that rebellious attitude let the GitHub team to go one step too far and create their own command `Factory` functions for dynamically generating commands in ways they they specifically want. That's fine, but why. Why not use `pkg/cmd` as Go gods intended for things like `pkg/cmd/kt/cmd.go` or `pkg/cmd/kt.go`. Using this method the directory structure can mirror that of the sub-trees as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters