NewPortsForwardCmd returns a Cobra "ports forward" subcommand, which forwards a set of port pairs from the codespace to localhost.
(app *App, selector *CodespaceSelector)
| 299 | // NewPortsForwardCmd returns a Cobra "ports forward" subcommand, which forwards a set of |
| 300 | // port pairs from the codespace to localhost. |
| 301 | func newPortsForwardCmd(app *App, selector *CodespaceSelector) *cobra.Command { |
| 302 | return &cobra.Command{ |
| 303 | Use: "forward <remote-port>:<local-port>...", |
| 304 | Short: "Forward ports", |
| 305 | Args: cobra.MinimumNArgs(1), |
| 306 | RunE: func(cmd *cobra.Command, args []string) error { |
| 307 | return app.ForwardPorts(cmd.Context(), selector, args) |
| 308 | }, |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | func (a *App) ForwardPorts(ctx context.Context, selector *CodespaceSelector, ports []string) (err error) { |
| 313 | portPairs, err := getPortPairs(ports) |
no test coverage detected