diff --git a/cli/cmd/encore/gen.go b/cli/cmd/encore/gen.go index f69c9c2135..798c0ba9e7 100644 --- a/cli/cmd/encore/gen.go +++ b/cli/cmd/encore/gen.go @@ -39,8 +39,8 @@ func init() { Short: "Generates an API client for your app", Long: `Generates an API client for your app. -By default generates the API based on your primary production environment. -Use '--env=local' to generate it based on your local development version of the app. +By default generates the API based on your local environment. +Use '--env=' to generate it based on your cloud environments. Supported language codes are: typescript: A TypeScript client using the Fetch API @@ -175,7 +175,7 @@ which may require the user-facing wrapper code to be manually generated.`, genClientCmd.Flags().StringVarP(&output, "output", "o", "", "The filename to write the generated client code to") _ = genClientCmd.MarkFlagFilename("output", "go", "ts", "tsx", "js", "jsx") - genClientCmd.Flags().StringVarP(&envName, "env", "e", "", "The environment to fetch the API for (defaults to the primary environment)") + genClientCmd.Flags().StringVarP(&envName, "env", "e", "local", "The environment to fetch the API for (defaults to the local environment)") _ = genClientCmd.RegisterFlagCompletionFunc("env", cmdutil.AutoCompleteEnvSlug) genClientCmd.Flags().StringSliceVarP(&genServiceNames, "services", "s", nil, "The names of the services to include in the output") diff --git a/cli/daemon/daemon.go b/cli/daemon/daemon.go index 6ec12155f7..4c6ee5a5e7 100644 --- a/cli/daemon/daemon.go +++ b/cli/daemon/daemon.go @@ -85,7 +85,13 @@ func New(appsMgr *apps.Manager, mgr *run.Manager, cm *sqldb.ClusterManager, sm * // GenClient generates a client based on the app's API. func (s *Server) GenClient(ctx context.Context, params *daemonpb.GenClientRequest) (*daemonpb.GenClientResponse, error) { var md *meta.Data - if params.EnvName == "local" { + + envName := params.EnvName + if envName == "" { + envName = "local" + } + + if envName == "local" { // Determine the app root app, err := s.apps.FindLatestByPlatformOrLocalID(params.AppId) if errors.Is(err, apps.ErrNotFound) { @@ -120,10 +126,6 @@ func (s *Server) GenClient(ctx context.Context, params *daemonpb.GenClientReques return nil, status.Errorf(codes.Internal, "failed to cache app metadata: %v", err) } } else { - envName := params.EnvName - if envName == "" { - envName = "@primary" - } meta, err := platform.GetEnvMeta(ctx, params.AppId, envName) if err != nil { if strings.Contains(err.Error(), "env_not_found") || strings.Contains(err.Error(), "env_not_deployed") {