func ParseArgs()

in fast-build-update-tool/internal/config/cli_args.go [60:101]


func ParseArgs(args []string) (CLIArgs, error) {
	result := CLIArgs{}

	flags := flag.NewFlagSet(AppName, flag.ContinueOnError)

	// Define required arguments
	flags.StringVar(&result.FleetId, argFleetId, "", "[Required] The ID of the GameLift Fleet to update")
	flags.StringVar(&result.IpRange, argIpRange, "", "[Required] Your local IP Address, needed to open ports on the fleet for remote connections (eg. 127.0.0.1/32)")
	flags.StringVar(&result.BuildZipPath, argBuildZipPath, "", "[Required] The path to the zip file containing your build")
	flags.StringVar(&result.PrivateKeyPath, argPrivateKey, "", "[Required] The local path to a private key to be used with SSH")

	// Define optional arguments
	flags.IntVar(&result.SSHPort, argSSHPort, 0, "[Optional] The port to open for SSH on the fleet. This option is for Windows remote instances only. It will default to 1026.")
	flags.StringVar(&result.instanceIdsRaw, argInstanceIds, "", "[Optional] A list of instance ids to update separated by comma. If not provided all instances will be updated")
	flags.BoolVar(&result.RestartProcess, argRestartProcess, false, "[Optional] Flag to restart existing game server processes on a server, and skip uploading a new build and replacing the old build.")
	flags.StringVar(&result.LockName, argLockName, AppName, "[Optional] This should only be set if you encounter a deadlock. This should not be set in typical application use. Set this argument to manually override the lock file name used on the server if your application gets stuck in an update deadlock.")
	flags.BoolVar(&result.Verbose, argVerbose, false, "[Optional] Write more verbose logs as output")

	flags.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s --%s FLEET_ID --%s IP_RANGE --%s BUILD_ZIP_PATH --%s PRIVATE_KEY \n", os.Args[0], argFleetId, argIpRange, argBuildZipPath, argPrivateKey)
		flags.PrintDefaults()
	}

	// If nothing was passed at all, show the usage instructions
	if len(args) <= 1 {
		flags.Usage()
		return result, flag.ErrHelp
	}

	// Parse the arguments (without the application exe in the slice)
	err := flags.Parse(args[1:])
	if err != nil {
		return result, err
	}

	// Split instance id CSV into a slice if provided
	if result.instanceIdsRaw != "" {
		result.InstanceIds = strings.Split(result.instanceIdsRaw, ",")
	}

	return result, nil
}