Skip to content

Commit f75104e

Browse files
committed
fix: Handle no workspaces case
1 parent 9e99d67 commit f75104e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cli/configssh.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,12 @@ func configSSH() *cobra.Command {
287287
}
288288
}
289289

290-
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "You should now be able to ssh into your workspace")
291-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "For example, try running:\n\n\t$ ssh coder.%s\n\n", workspaces[0].Name)
290+
if len(workspaces) > 0 {
291+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "You should now be able to ssh into your workspace")
292+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "For example, try running:\n\n\t$ ssh coder.%s\n\n", workspaces[0].Name)
293+
} else {
294+
_, _ = fmt.Fprint(cmd.OutOrStdout(), "You don't have any workspaces yet, try creating one with:\n\n\t$ coder create <workspace>\n\n")
295+
}
292296
return nil
293297
},
294298
}

0 commit comments

Comments
 (0)