Initialize a new CLI project using the cobra-cli tool to generate the root command and main entry point.
-
Install the Cobra CLI generator.
go install github.com/spf13/cobra-cli@latest -
Generate a new project named
myapp.cobra-cli init myapp -
Change into the new project directory.
cd myapp -
Add a subcommand named
runto the root command.cobra-cli add run -
Build the executable binary.
go build -o myapp -
Run the CLI to verify the help output.
./myapp --help