func (cmd *CommandCreate) Handler(profile *user.Profile, ui terminal.UI, clients cli.Clients) error {
	appRemote, err := cmd.inputs.resolveRemoteApp(ui, clients.Realm)
	if err != nil {
		return err
	}
	groupID := cmd.inputs.Project
	if groupID == "" {
		groupID = appRemote.GroupID
	}
	if groupID == "" {
		groupID, err = cli.ResolveGroupID(ui, clients.Atlas)
		if err != nil {
			return err
		}
	}
	err = cmd.inputs.resolveName(ui, clients.Realm, appRemote.GroupID, appRemote.ClientAppID)
	if err != nil {
		return err
	}
	rootDir, err := cmd.inputs.resolveLocalPath(ui, profile.WorkingDirectory)
	if err != nil {
		return err
	}
	if err := cmd.inputs.resolveTemplateID(clients.Realm); err != nil {
		return err
	}
	dsClusters, dsClustersMissing, err := cmd.inputs.resolveClusters(ui, clients.Atlas, groupID)
	if err != nil {
		return err
	}
	var dsDatalakes []dataSourceDatalake
	var dsDatalakesMissing []string
	if len(cmd.inputs.Datalakes) > 0 {
		dsDatalakes, dsDatalakesMissing, err = cmd.inputs.resolveDatalakes(ui, clients.Atlas, groupID)
		if err != nil {
			return err
		}
	}
	nonExistingDataSources := make([]string, 0, len(dsClustersMissing)+len(dsDatalakesMissing))
	for _, missingCluster := range dsClustersMissing {
		nonExistingDataSources = append(nonExistingDataSources, fmt.Sprintf("'%s'", missingCluster))
	}
	for _, missingDatalake := range dsDatalakesMissing {
		nonExistingDataSources = append(nonExistingDataSources, fmt.Sprintf("'%s'", missingDatalake))
	}
	if len(nonExistingDataSources) > 0 {
		ui.Print(terminal.NewWarningLog("Note: The following data sources were not linked because they could not be found: %s", strings.Join(nonExistingDataSources, ", ")))
		proceed, err := ui.Confirm("Would you still like to create the app?")
		if err != nil {
			return err
		}
		if !proceed {
			return nil
		}
	}
	if cmd.inputs.Template == "" {
		return cmd.handleCreateApp(profile, ui, clients, groupID, rootDir, appRemote, dsClusters, dsDatalakes)
	}
	return cmd.handleCreateTemplateApp(profile, ui, clients, groupID, rootDir, dsClusters, dsDatalakes)
}
Handler is the command handler
package app
import (
	"errors"
	"fmt"
	"os"
	"path"
	"path/filepath"
	"strings"
	"github.com/10gen/realm-cli/internal/cli"
	"github.com/10gen/realm-cli/internal/cli/user"
	"github.com/10gen/realm-cli/internal/cloud/realm"
	"github.com/10gen/realm-cli/internal/local"
	"github.com/10gen/realm-cli/internal/telemetry"
	"github.com/10gen/realm-cli/internal/terminal"
	"github.com/10gen/realm-cli/internal/utils/flags"
)
var CommandMetaCreate = cli.CommandMeta{
	Use:         "create",
	Display:     "app create",
	Description: "Create a new app from your current working directory and deploy it to the Realm server",
	HelpText: `Creates a new Realm app by saving your configuration files in a local directory
and deploying the new app to the Realm server. This command will create a new
directory for your project.
You can specify a "--remote" flag to create a Realm app from an existing app;
if you do not specify a "--remote" flag, the CLI will create a default Realm app.
NOTE: To create a Realm app without deploying it, use "app init".`,
}
type CommandCreate struct {
	inputs createInputs
}
func (cmd *CommandCreate) Flags() []flags.Flag {
	return []flags.Flag{
		remoteAppFlag(&cmd.inputs.RemoteApp),
		flags.StringFlag{
			Value: &cmd.inputs.LocalPath,
			Meta: flags.Meta{
				Name: flagLocalPathCreate,
				Usage: flags.Usage{
					Description: "Specify the local filepath of a Realm app to be created",
				},
			},
		},
		nameFlag(&cmd.inputs.Name),
		locationFlag(&cmd.inputs.Location),
		deploymentModelFlag(&cmd.inputs.DeploymentModel),
		environmentFlag(&cmd.inputs.Environment),
		flags.StringSliceFlag{
			Value: &cmd.inputs.Clusters,
			Meta: flags.Meta{
				Name: flagCluster,
				Usage: flags.Usage{
					Description: "Link Atlas cluster(s) to your Realm app",
					Note:        "Only one cluster can be linked during app creation if creating a template app",
				},
			},
		},
		flags.StringSliceFlag{
			Value: &cmd.inputs.ClusterServiceNames,
			Meta: flags.Meta{
				Name: flagClusterServiceName,
				Usage: flags.Usage{
					Description: "Specify the Realm app Service name to reference your Atlas cluster",
					Note:        "Service names will be overwritten when creating a template app",
				},
			},
		},
		flags.StringSliceFlag{
			Value: &cmd.inputs.Datalakes,
			Meta: flags.Meta{
				Name: flagDatalake,
				Usage: flags.Usage{
					Description: "Link Atlas data lake(s) to your Realm app",
					Note:        "Data lakes cannot be used to create template apps",
				},
			},
		},
		flags.StringSliceFlag{
			Value: &cmd.inputs.DatalakeServiceNames,
			Meta: flags.Meta{
				Name: flagDatalakeServiceName,
				Usage: flags.Usage{
					Description: "Specify the Realm app Service name to reference your Atlas data lake",
				},
			},
		},
		flags.StringFlag{
			Value: &cmd.inputs.Template,
			Meta: flags.Meta{
				Name: flagTemplate,
				Usage: flags.Usage{
					Description:   "Create your Realm app from an available template",
					AllowedValues: realm.AllowedTemplates,
				},
			},
		},
		flags.BoolFlag{
			Value: &cmd.inputs.DryRun,
			Meta: flags.Meta{
				Name:      flagDryRun,
				Shorthand: "x",
				Usage: flags.Usage{
					Description: "Run without writing any changes to the local filepath or pushing any changes to the Realm server",
				},
			},
		},
		cli.ProjectFlag(&cmd.inputs.Project),
		cli.ConfigVersionFlag(&cmd.inputs.ConfigVersion, flagConfigVersionDescription),
	}
}
func (cmd *CommandCreate) Inputs() cli.InputResolver {
	return &cmd.inputs
}
func (cmd *CommandCreate) AdditionalTrackedFields() []telemetry.EventData {
	if cmd.inputs.Template == "" {
		return nil
	}
	return []telemetry.EventData{
		{Key: telemetry.EventDataKeyTemplate, Value: cmd.inputs.Template},
	}
}