X Tutup
Skip to content

Commit b2598d6

Browse files
committed
start codespace to fetch config if it's explicitly requested
When running `gh cs ssh config` without a `-c` option, we skip codespaces that aren't available. This change suppresses that behavior when a single codespace is explicitly requested, starting the codespace if it's not running.
1 parent 6182399 commit b2598d6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/cmd/codespace/ssh.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts configOptions) error
194194
fetches := 0
195195
var status error
196196
for _, cs := range codespaces {
197-
if cs.State != "Available" {
197+
if cs.State != "Available" && opts.codespace == "" {
198198
fmt.Fprintf(os.Stderr, "skipping unavailable codespace %s: %s\n", cs.Name, cs.State)
199199
status = cmdutil.SilentError
200200
continue
@@ -423,7 +423,7 @@ func newConfigCmd(app *App) *cobra.Command {
423423
configCmd := &cobra.Command{
424424
Use: "config [-c codespace]",
425425
Short: "Write OpenSSH configuration to stdout",
426-
Long: heredoc.Docf(`
426+
Long: heredoc.Doc(`
427427
The config command generates per-codespace ssh configuration in OpenSSH format.
428428
429429
Including this configuration in ~/.ssh/config improves the user experience of other
@@ -433,9 +433,10 @@ func newConfigCmd(app *App) *cobra.Command {
433433
If -c/--codespace is specified, configuration is generated for that codespace
434434
only. Otherwise configuration is emitted for all available codespaces.
435435
436-
Codespaces that aren't in "Available" state are skipped because it's necessary to
437-
connect to the running codespace to determine the required remote ssh username.
438-
`, "`"),
436+
When generating configuration for all codespaces, ones that aren't in "Available"
437+
state are skipped because it's necessary to start the codespace to determine its
438+
remote ssh username. When generating configuration for a single codespace with '-c',
439+
`),
439440
Example: heredoc.Doc(`
440441
$ gh codespace config > ~/.ssh/codespaces
441442
$ echo 'include ~/.ssh/codespaces' >> ~/.ssh/config'

0 commit comments

Comments
 (0)
X Tutup