Cobra Bool Flags

Hi,

I just started Golang (my first programming language).

Please I am trying to write a CLI app that will have the following command:

tk8 cluster aws

But I want the following flags to behave like this:

tk8 cluster aws --cloud (Initiate a cloud infrrastructure with necessary elements e.g EC2, VPC, etc)

tk8 cluster aws --install (start kubernetes installation on the AWS cloud)

Current code I have is this:

// Copyright © 2018 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"os/exec"

	"github.com/spf13/cobra"
)

var install,cloud string

// awsCmd represents the aws command
var awsCmd = &cobra.Command{
	Use:   "aws",
	Short: "Manages the infrastructure on AWS",
	Long: `Create, delete and show current status of the deployment that is running on AWS.
	Kindly ensure that terraform is installed also.`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Testing")
	},
}

func init() {
	clusterCmd.AddCommand(awsCmd)
	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// awsCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// awsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	awsCmd.Flags().BoolP(install, "i", true, "Start Kubernetes deployment on AWS")
        awsCmd.Flags().BoolP(cloud, "c", true, "Deploy Cloud Infra on AWS")

}

I already have the codes snippets that will perform the installation but I don’t know where I should call the flags and then insert the code with respect to the command flags.

Not to worry again,

I have discovered the solution.