@@ -11,6 +11,7 @@ import (
1111 "github.com/render-oss/cli/pkg/dependencies"
1212 "github.com/render-oss/cli/pkg/postgres"
1313 "github.com/render-oss/cli/pkg/text"
14+ "github.com/render-oss/cli/pkg/tui/views"
1415 "github.com/render-oss/cli/pkg/types"
1516 pgtypes "github.com/render-oss/cli/pkg/types/postgres"
1617)
@@ -23,21 +24,28 @@ func newPgCreateCmd(deps *dependencies.Dependencies) *cobra.Command {
2324 SilenceUsage : true ,
2425 Long : `Create a new Postgres database on Render.
2526
26- Every flag is optional: running 'render ea pg create' with no flags provisions
27- a database in the active workspace with sensible defaults.
27+ In interactive mode, a wizard guides you through the core choices for the
28+ database. The wizard owns those prompted values. Flag-only settings, such as
29+ --disk-size-gb, --database-name, --database-user, --ip-allow-list,
30+ --parameter-override, and --read-replica, are still included in the create
31+ request.
2832
29- Output defaults to text. Use --output json or --output yaml for
30- machine-readable output.
33+ Use --confirm to skip the wizard and create immediately from flags and defaults.
34+ When --confirm is used with the default interactive output mode, output is
35+ printed as text. Use --output json, yaml, or text for non-interactive output.
3136
3237Examples:
33- # Create with all defaults
38+ # Launch the interactive wizard
3439 render ea pg create
3540
36- # Pick a plan, version, and region
37- render ea pg create --name analytics --plan pro_8gb --version 17 --region ohio
41+ # Create immediately with defaults and text output
42+ render ea pg create --confirm
3843
39- # Restrict inbound traffic (repeat the flag for multiple entries)
40- render ea pg create --name analytics \
44+ # Create immediately with explicit values
45+ render ea pg create --confirm --name analytics --plan pro_8gb --version 17 --region ohio
46+
47+ # Include flag-only settings while using the wizard for prompted values
48+ render ea pg create \
4149 --ip-allow-list "cidr=203.0.113.5/32,description=office" \
4250 --ip-allow-list "cidr=10.0.0.0/8,description=internal"
4351
@@ -77,21 +85,40 @@ Examples:
7785 "Name of a read replica to create alongside the primary. Repeat the flag for multiple replicas." )
7886
7987 cmd .RunE = func (cmd * cobra.Command , args []string ) error {
80- command .DefaultFormatNonInteractive (cmd )
88+ if command .GetConfirmFromContext (cmd .Context ()) {
89+ command .DefaultFormatNonInteractive (cmd )
90+ }
8191
8292 var input pgtypes.CreatePostgresInput
8393 if err := command .ParseCommand (cmd , args , & input ); err != nil {
8494 return err
8595 }
8696
87- _ , err := command .NonInteractive (cmd ,
97+ // There are two execution paths:
98+ // 1. Non-interactive output (text/json/yaml): create and print via the shared formatter.
99+ // 2. Interactive output: run the TUI wizard, which owns its styled output.
100+ // --confirm skips prompts, so collapse default interactive output to text before
101+ // this gate. command.NonInteractive returns (false, nil) only when the resolved
102+ // output format is still interactive, without calling loadData.
103+ nonInteractive , err := command .NonInteractive (cmd ,
88104 func () (* client.PostgresDetail , error ) {
89105 return deps .PostgresService ().Create (cmd .Context (), input )
90106 },
91107 func (pg * client.PostgresDetail ) string {
92108 return pgCreateSuccessMessage (pg )
93109 },
94110 )
111+ if err != nil || nonInteractive {
112+ return err
113+ }
114+
115+ repos := views.PostgresCreateRepos {
116+ Owners : deps .OwnerRepo (),
117+ Projects : deps .ProjectRepo (),
118+ Envs : deps .EnvironmentRepo (),
119+ Postgres : deps .PostgresRepo (),
120+ }
121+ _ , err = views .RunPostgresCreate (cmd , repos , input )
95122 return err
96123 }
97124
0 commit comments