#Task
This command, as described in its help message, is a "Wrapper/Organizer for subcommands that perform actions on servers".
All the commands that fall under the actions command will use the following for their `func init()`:
```go
func init() {
actionsCmd.AddCommand(consoleCmd)
}
```
All the commands that don't fall under the actions command just use this instead:
```go
func init() {
rootCmd.AddCommand(authCmd)
}
```
This is just how Cobra in Golang structures their commands. Each command will fall under the root command and, if you want to compartmentalize further, you can put commands under other subcommands. An example would be:
```bash
mc-auto actions console
```
Rather than just:
```basb
mc-auto console
```
As you can imagine, if you put every command under the basic root command, the main help page gets crowded quickly and it's harder to categorize the functions in your head.
Our current command displays help like this:
```bash
jacobhathaway@JacobsPC:~/workspace/github.com/cogitativejacob/minecraftautomatorpre/mc-auto$ go run main.go
A CLI tool to automatically provision Minecraft servers
Usage:
mc-auto [command]
Available Commands:
actions Wrapper/Organizer for subcommands that perform actions on servers
auth Login with your Google account to create a user/token
completion Generate the autocompletion script for the specified shell
create Create a new server
delete Delete a server by ID
details Get details of a server by ID
help Help about any command
list List all servers
Flags:
-h, --help help for mc-auto
-k, --insecure Use this flag if your API does not use TLS/SSL
Use "mc-auto [command] --help" for more information about a command.
```
So some commands are hidden under actions:
```bash
jacobhathaway@JacobsPC:~/workspace/github.com/cogitativejacob/minecraftautomatorpre/mc-auto$ go run main.go actions -h
Wrapper/Organizer for subcommands that perform actions on servers
Usage:
mc-auto actions [flags]
mc-auto actions [command]
Available Commands:
console View logs on a server by ID
rcon Send RCON commands to a server by ID
restart Restart a server by ID
Flags:
-h, --help help for actions
Global Flags:
-k, --insecure Use this flag if your API does not use TLS/SSL
Use "mc-auto actions [command] --help" for more information about a command.
```
So the entire actions file looks like this:
```go
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// actionsCmd represents the actions command
var actionsCmd = &cobra.Command{
Use: "actions",
Short: "Wrapper/Organizer for subcommands that perform actions on servers",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Use actions -h to see possible commands")
},
}
func init() {
rootCmd.AddCommand(actionsCmd)
}
```
- That Run key is what runs when you call the command directly, so, when you call actions directly, that function runs to tell you to check the possible subcommands since actions doesn't do anything by itself.