@@ -45,28 +45,38 @@ type CreateReturnContext = CreateContext & {
4545 readonly view : Extract < ViewState , { readonly _tag : "Create" } >
4646}
4747
48+ type OptionalCreateArg = {
49+ readonly value : string
50+ readonly args : readonly [ string , string ]
51+ }
52+
53+ const optionalCreateArgs = ( input : CreateInputs ) : ReadonlyArray < OptionalCreateArg > => [
54+ { value : input . repoUrl , args : [ "--repo-url" , input . repoUrl ] } ,
55+ { value : input . repoRef , args : [ "--repo-ref" , input . repoRef ] } ,
56+ { value : input . outDir , args : [ "--out-dir" , input . outDir ] } ,
57+ { value : input . cpuLimit , args : [ "--cpu" , input . cpuLimit ] } ,
58+ { value : input . ramLimit , args : [ "--ram" , input . ramLimit ] }
59+ ]
60+
61+ const booleanCreateFlags = ( input : CreateInputs ) : ReadonlyArray < string > =>
62+ [
63+ input . runUp ? null : "--no-up" ,
64+ input . enableMcpPlaywright ? "--mcp-playwright" : null ,
65+ input . force ? "--force" : null ,
66+ input . forceEnv ? "--force-env" : null
67+ ] . filter ( ( value ) : value is string => value !== null )
68+
4869export const buildCreateArgs = ( input : CreateInputs ) : ReadonlyArray < string > => {
4970 const args : Array < string > = [ "create" ]
50- if ( input . repoUrl . length > 0 ) {
51- args . push ( "--repo-url" , input . repoUrl )
52- }
53- if ( input . repoRef . length > 0 ) {
54- args . push ( "--repo-ref" , input . repoRef )
55- }
56- if ( input . outDir . length > 0 ) {
57- args . push ( "--out-dir" , input . outDir )
58- }
59- if ( ! input . runUp ) {
60- args . push ( "--no-up" )
61- }
62- if ( input . enableMcpPlaywright ) {
63- args . push ( "--mcp-playwright" )
64- }
65- if ( input . force ) {
66- args . push ( "--force" )
71+
72+ for ( const spec of optionalCreateArgs ( input ) ) {
73+ if ( spec . value . length > 0 ) {
74+ args . push ( spec . args [ 0 ] , spec . args [ 1 ] )
75+ }
6776 }
68- if ( input . forceEnv ) {
69- args . push ( "--force-env" )
77+
78+ for ( const flag of booleanCreateFlags ( input ) ) {
79+ args . push ( flag )
7080 }
7181 return args
7282}
@@ -118,6 +128,8 @@ export const resolveCreateInputs = (
118128 repoUrl,
119129 repoRef : values . repoRef ?? resolvedRepoRef ?? "main" ,
120130 outDir,
131+ cpuLimit : values . cpuLimit ?? "" ,
132+ ramLimit : values . ramLimit ?? "" ,
121133 runUp : values . runUp !== false ,
122134 enableMcpPlaywright : values . enableMcpPlaywright === true ,
123135 force : values . force === true ,
@@ -196,6 +208,14 @@ const applyCreateStep = (input: {
196208 input . nextValues . outDir = input . buffer . length > 0 ? input . buffer : input . currentDefaults . outDir
197209 return true
198210 } ) ,
211+ Match . when ( "cpuLimit" , ( ) => {
212+ input . nextValues . cpuLimit = input . buffer . length > 0 ? input . buffer : input . currentDefaults . cpuLimit
213+ return true
214+ } ) ,
215+ Match . when ( "ramLimit" , ( ) => {
216+ input . nextValues . ramLimit = input . buffer . length > 0 ? input . buffer : input . currentDefaults . ramLimit
217+ return true
218+ } ) ,
199219 Match . when ( "runUp" , ( ) => {
200220 input . nextValues . runUp = parseYesDefault ( input . buffer , input . currentDefaults . runUp )
201221 return true
0 commit comments