clean up gh cs ssh option parsing/validation
This commit is contained in:
parent
c9d0085e57
commit
8687fcb2a0
1 changed files with 4 additions and 10 deletions
|
|
@ -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`")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue