At a high level, these areas make up the github.com/abc-inc/heimdall project:
cmd/-mainpackages for building theheimdallexecutablecli/- most other CLI code, including different output formats and the REPLdocs/- documentation for maintainers and contributorsplugin/- contains sub-commandsres- provides utilities for all kinds of file operations
- Create a new file for the new command, e.g.
plugin/<type>/custom.go - The new command should expose a method, e.g.
NewCustomCmd(), that returns a*cobra.Command.- Any logic specific to this command should be kept within the package and not added to any "global" package.
- Use the method from the previous step to generate the command and add it to the command tree, typically somewhere at the root command.
This task might be tricky. Typically, Heimdall commands do things like look up information from remote files. Moreover, one does not want to test the CLI framework, rather than the command itself. To avoid that, you may want to define function, which do not contain any CLI-related code. Export those functions, if necessary.
To make your code testable, write small, isolated pieces of functionality that are designed to be composed together. Prefer table-driven tests for maintaining variations of different test inputs and expectations when exercising a single piece of functionality.