Skip to content

Commit 7a4b8d6

Browse files
committed
fix: Handle no workspaces case
1 parent 9680792 commit 7a4b8d6

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
@@ -285,8 +285,12 @@ func configSSH() *cobra.Command {
285285
}
286286
}
287287

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

0 commit comments

Comments
 (0)