Cmd Client
This service is shipped with a cmd client, which means you can use ./go-boilerplate
to view all available commands and help menu.
You need to build the service first before you can use go-boilerplate
both ./go-boilerplate
and go run .
can be followed by any flags, commands and sub-commands
The command line client is intended to be a thin layer that enable the interaction with the service,
The rest of the execution logic is left to the proc
(process) part of the package.
The command line client is built using the cobra
package, which is a powerful library for building command line applications in Go.
It provides a simple and intuitive way to define commands, flags, and arguments, and automatically generates help messages and documentation for your commands.
The Command Line Client
This implementation is no differenet, as soon as you invoke the go-boilerplate
command, it will display the help message with all available commands and flags.
From there, you would want to focus on three areas,
the start
command, the db
command and the info
command.
Each of these commands has its own set of sub-commands and flags that you can use to interact with the service.
you can also use the -h
or --help
flag to get more information about each command and its sub-commands.
Start Command
The start
command is the main entry point for the service, it will start the service and listen for incoming requests.
DB Command
The db
command is used to manage the database, it has several sub-commands that you can use to interact with the database.
Info Command
The info
command is used to display information about the service, such as the version, build date, and commit hash.
More Commands
You can use the go-boilerplate -h
command to see a list of all available commands and their sub-commands.
Flags
The cmd client supports several flags that you can use to customize the behavior of the service.
The below flags are available with the start
command, they're generally the most used flags in the day to day operations.
If you want to see all available flags, you can use the go-boilerplate -h
command to see a list of all available flags and their descriptions.
Flag Name | Shorthand | type | Description |
---|---|---|---|
--dev | -d | bool | Run in development mode |
--env | -e | bool | Print environment variables |
--host | -H | string | (optional) Service host. Overrides env vars |
--port | -P | string | (optional) Service port. Overrides env vars |
--watcher | (N/A) | bool | (optional) Start watcher in the backgoround |
--log | -l | string | (optional) Log level |
Extending the Cmd Client
The cmd client is designed to be extensible, you can add your own commands and sub-commands to the client by creating a new file in the cmd
package and defining your command there.
Tasks
You can also use the cmd client to run tasks, which are executable commands that can be run independently of the service.
Coming Soon...
See the Tasks section for more information on how to create and run tasks.