MCPcopy
hub / github.com/cli/cli / newPortsCmd

Function newPortsCmd

pkg/cmd/codespace/ports.go:27–50  ·  view source on GitHub ↗

newPortsCmd returns a Cobra "ports" command that displays a table of available ports, according to the specified flags.

(app *App)

Source from the content-addressed store, hash-verified

25// newPortsCmd returns a Cobra "ports" command that displays a table of available ports,
26// according to the specified flags.
27func newPortsCmd(app *App) *cobra.Command {
28 var (
29 selector *CodespaceSelector
30 exporter cmdutil.Exporter
31 )
32
33 portsCmd := &cobra.Command{
34 Use: "ports",
35 Short: "List ports in a codespace",
36 Args: noArgsConstraint,
37 RunE: func(cmd *cobra.Command, args []string) error {
38 return app.ListPorts(cmd.Context(), selector, exporter)
39 },
40 }
41
42 selector = AddCodespaceSelector(portsCmd, app.apiClient)
43
44 cmdutil.AddJSONFlags(portsCmd, &exporter, portFields)
45
46 portsCmd.AddCommand(newPortsForwardCmd(app, selector))
47 portsCmd.AddCommand(newPortsVisibilityCmd(app, selector))
48
49 return portsCmd
50}
51
52// ListPorts lists known ports in a codespace.
53func (a *App) ListPorts(ctx context.Context, selector *CodespaceSelector, exporter cmdutil.Exporter) (err error) {

Callers 1

NewCmdCodespaceFunction · 0.85

Calls 5

AddJSONFlagsFunction · 0.92
AddCodespaceSelectorFunction · 0.85
newPortsForwardCmdFunction · 0.85
newPortsVisibilityCmdFunction · 0.85
ListPortsMethod · 0.65

Tested by

no test coverage detected