clean up gh cs ssh option parsing/validation

This commit is contained in:
Jason Lunz 2021-12-16 15:18:59 -07:00
parent c9d0085e57
commit 8687fcb2a0
No known key found for this signature in database
GPG key ID: 88F9FD38589448E9

View file

@ -40,20 +40,14 @@ func newSSHCmd(app *App) *cobra.Command {
Use: "ssh [<flags>...] [-- <ssh-flags>...] [<command>]",
Short: "SSH into a codespace",
PreRunE: func(c *cobra.Command, args []string) error {
f := c.Flags()
codespaceFlag := f.Lookup("codespace")
portFlag := f.Lookup("server-port")
profileFlag := f.Lookup("profile")
stdioFlag := f.Lookup("stdio")
if stdioFlag.Changed {
if !codespaceFlag.Changed {
if opts.stdio {
if opts.codespace == "" {
return errors.New("`--stdio` requires explicit `--codespace`")
}
if portFlag.Changed {
if opts.serverPort != 0 {
return errors.New("cannot use `--stdio` with `--server-port`")
}
if profileFlag.Changed {
if opts.profile != "" {
return errors.New("cannot use `--stdio` with `--profile`")
}
}