@@ -204,7 +204,7 @@ async function promptForAgent(): Promise<string> {
204204 return agentHost ;
205205}
206206
207- async function getClient ( timeoutMs ?: number ) {
207+ async function createClient ( timeoutMs ?: number ) {
208208 const agent = await getAgentWithFallback ( ) ;
209209 return createApiClient ( agent , undefined , timeoutMs ) ;
210210}
@@ -237,7 +237,7 @@ program
237237 . description ( 'List all workspaces' )
238238 . action ( async ( ) => {
239239 try {
240- const client = await getClient ( ) ;
240+ const client = await createClient ( ) ;
241241 const workspaces = await client . listWorkspaces ( ) ;
242242
243243 if ( workspaces . length === 0 ) {
@@ -273,7 +273,7 @@ program
273273 . option ( '--clone <url>' , 'Git repository URL to clone (when creating)' )
274274 . action ( async ( name , options ) => {
275275 try {
276- const client = await getClient ( ) ;
276+ const client = await createClient ( ) ;
277277 console . log ( `Starting workspace '${ name } '...` ) ;
278278
279279 let workspace ;
@@ -316,7 +316,7 @@ program
316316 . description ( 'Stop a running workspace' )
317317 . action ( async ( name ) => {
318318 try {
319- const client = await getClient ( ) ;
319+ const client = await createClient ( ) ;
320320 console . log ( `Stopping workspace '${ name } '...` ) ;
321321
322322 const workspace = await client . stopWorkspace ( name ) ;
@@ -333,7 +333,7 @@ program
333333 . description ( 'Delete a workspace' )
334334 . action ( async ( name ) => {
335335 try {
336- const client = await getClient ( ) ;
336+ const client = await createClient ( ) ;
337337 console . log ( `Deleting workspace '${ name } '...` ) ;
338338
339339 await client . deleteWorkspace ( name ) ;
@@ -349,7 +349,7 @@ program
349349 . description ( 'Clone an existing workspace' )
350350 . action ( async ( source , cloneName ) => {
351351 try {
352- const client = await getClient ( ) ;
352+ const client = await createClient ( ) ;
353353 console . log ( `Cloning workspace '${ source } ' to '${ cloneName } '...` ) ;
354354 console . log ( 'This may take a while for large workspaces.' ) ;
355355
@@ -368,7 +368,7 @@ program
368368 . description ( 'Show workspace or agent info' )
369369 . action ( async ( name ) => {
370370 try {
371- const client = await getClient ( ) ;
371+ const client = await createClient ( ) ;
372372
373373 if ( name ) {
374374 const workspace = await client . getWorkspace ( name ) ;
@@ -405,7 +405,7 @@ program
405405 . option ( '-n, --tail <lines>' , 'Number of lines to show' , '100' )
406406 . action ( async ( name , options ) => {
407407 try {
408- const client = await getClient ( ) ;
408+ const client = await createClient ( ) ;
409409 const logs = await client . getLogs ( name , parseInt ( options . tail , 10 ) ) ;
410410 console . log ( logs ) ;
411411 } catch ( err ) {
@@ -419,7 +419,7 @@ program
419419 . option ( '-a, --all' , 'Sync all running workspaces' )
420420 . action ( async ( name , options ) => {
421421 try {
422- const client = await getClient ( 5 * 60 * 1000 ) ;
422+ const client = await createClient ( 5 * 60 * 1000 ) ;
423423
424424 if ( options . all ) {
425425 console . log ( 'Syncing all running workspaces...' ) ;
@@ -462,7 +462,7 @@ program
462462 . action ( async ( name ) => {
463463 try {
464464 const agentHost = await getAgentWithFallback ( ) ;
465- const client = await getClient ( ) ;
465+ const client = await createClient ( ) ;
466466
467467 const workspace = await client . getWorkspace ( name ) ;
468468 if ( workspace . status !== 'running' ) {
@@ -508,7 +508,7 @@ program
508508 . action ( async ( name , ports : string [ ] ) => {
509509 try {
510510 const agentHost = await getAgentWithFallback ( ) ;
511- const client = await getClient ( ) ;
511+ const client = await createClient ( ) ;
512512
513513 const workspace = await client . getWorkspace ( name ) ;
514514 if ( workspace . status !== 'running' ) {
@@ -602,7 +602,7 @@ program
602602 . description ( 'Configure port mappings for a workspace (e.g. 3000, 8080:3000)' )
603603 . action ( async ( name , ports : string [ ] ) => {
604604 try {
605- const client = await getClient ( ) ;
605+ const client = await createClient ( ) ;
606606
607607 const workspace = await client . getWorkspace ( name ) ;
608608 if ( ! workspace ) {
@@ -793,7 +793,7 @@ sshCmd
793793 . description ( 'Show current SSH configuration' )
794794 . action ( async ( ) => {
795795 try {
796- const client = await getClient ( ) ;
796+ const client = await createClient ( ) ;
797797 const ssh = await client . getSSHSettings ( ) ;
798798
799799 console . log ( '' ) ;
@@ -844,7 +844,7 @@ sshCmd
844844 . description ( 'Toggle auto-authorization of host keys (on/off)' )
845845 . action ( async ( toggle ?: string ) => {
846846 try {
847- const client = await getClient ( ) ;
847+ const client = await createClient ( ) ;
848848 const settings = await client . getSSHSettings ( ) ;
849849
850850 if ( ! toggle ) {
@@ -871,7 +871,7 @@ sshCmd
871871 . option ( '-w, --workspace <name>' , 'Apply to specific workspace only' )
872872 . action ( async ( keyPath : string , options : { workspace ?: string } ) => {
873873 try {
874- const client = await getClient ( ) ;
874+ const client = await createClient ( ) ;
875875 const settings = await client . getSSHSettings ( ) ;
876876
877877 const normalizedPath = keyPath . replace ( / \. p u b $ / , '' ) ;
@@ -907,7 +907,7 @@ sshCmd
907907 . option ( '-w, --workspace <name>' , 'Apply to specific workspace only' )
908908 . action ( async ( keyPath : string , options : { workspace ?: string } ) => {
909909 try {
910- const client = await getClient ( ) ;
910+ const client = await createClient ( ) ;
911911 const settings = await client . getSSHSettings ( ) ;
912912
913913 if ( options . workspace ) {
@@ -947,7 +947,7 @@ sshCmd
947947 options : { workspace ?: string ; copy ?: boolean ; authorize ?: boolean }
948948 ) => {
949949 try {
950- const client = await getClient ( ) ;
950+ const client = await createClient ( ) ;
951951 const settings = await client . getSSHSettings ( ) ;
952952
953953 const normalizedPath = keyPath . replace ( / \. p u b $ / , '' ) ;
@@ -1254,7 +1254,7 @@ function handleError(err: unknown): never {
12541254 console . error ( `Error: ${ JSON . stringify ( err ) } ` ) ;
12551255 }
12561256 } else if ( err !== undefined && err !== null ) {
1257- console . error ( ` Error: ${ String ( err ) } ` ) ;
1257+ console . error ( ' Error:' , err ) ;
12581258 } else {
12591259 console . error ( 'An unknown error occurred' ) ;
12601260 }
0 commit comments