Skip to content

Commit 8687fcb

Browse files
committed
clean up gh cs ssh option parsing/validation
1 parent c9d0085 commit 8687fcb

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pkg/cmd/codespace/ssh.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,14 @@ func newSSHCmd(app *App) *cobra.Command {
4040
Use: "ssh [<flags>...] [-- <ssh-flags>...] [<command>]",
4141
Short: "SSH into a codespace",
4242
PreRunE: func(c *cobra.Command, args []string) error {
43-
f := c.Flags()
44-
codespaceFlag := f.Lookup("codespace")
45-
portFlag := f.Lookup("server-port")
46-
profileFlag := f.Lookup("profile")
47-
stdioFlag := f.Lookup("stdio")
48-
49-
if stdioFlag.Changed {
50-
if !codespaceFlag.Changed {
43+
if opts.stdio {
44+
if opts.codespace == "" {
5145
return errors.New("`--stdio` requires explicit `--codespace`")
5246
}
53-
if portFlag.Changed {
47+
if opts.serverPort != 0 {
5448
return errors.New("cannot use `--stdio` with `--server-port`")
5549
}
56-
if profileFlag.Changed {
50+
if opts.profile != "" {
5751
return errors.New("cannot use `--stdio` with `--profile`")
5852
}
5953
}

0 commit comments

Comments
 (0)