v2.30.0-pre3 63e7f3a

autoroute_allow.go RawHistoryFolder

1package cli
2
3import (
4	"context"
5	"fmt"
6	"io"
7
8	"github.com/spf13/cobra"
9)
10
11func newAutorouteCmd() *cobra.Command {
12	cmd := &cobra.Command{
13		Use:   "autoroute",
14		Short: "Manage auto-route settings",
15	}
16	cmd.AddCommand(newAutorouteAllowCmd())
17	return cmd
18}
19
20func newAutorouteAllowCmd() *cobra.Command {
21	cmd := &cobra.Command{
22		Use:   "allow",
23		Short: "Manage auto-route allowed domains",
24	}
25	cmd.AddCommand(newAutorouteAllowAddCmd())
26	cmd.AddCommand(newAutorouteAllowListCmd())
27	cmd.AddCommand(newAutorouteAllowRemoveCmd())
28	return cmd
29}
30
31func newAutorouteAllowAddCmd() *cobra.Command {
32	return &cobra.Command{
33		Use:   "add <pattern>",
34		Short: "Allow an auto-route domain pattern",
35		Args:  cobra.ExactArgs(1),
36		RunE: func(cmd *cobra.Command, args []string) error {
37			return runAutorouteAllowAdd(cmd.Context(), args, cmd.OutOrStdout())
38		},
39	}
40}
41
42func newAutorouteAllowListCmd() *cobra.Command {
43	var jsonOut bool
44	cmd := &cobra.Command{
45		Use:   "list",
46		Short: "List auto-route allowed domains",
47		RunE: func(cmd *cobra.Command, args []string) error {
48			return runAutorouteAllowList(cmd.Context(), cmd.OutOrStdout(), jsonOut)
49		},
50	}
51	cmd.Flags().BoolVar(&jsonOut, "json", false, "Output as JSON")
52	return cmd
53}
54
55func newAutorouteAllowRemoveCmd() *cobra.Command {
56	return &cobra.Command{
57		Use:   "remove <pattern>",
58		Short: "Remove an auto-route domain pattern",
59		Args:  cobra.ExactArgs(1),
60		RunE: func(cmd *cobra.Command, args []string) error {
61			return runAutorouteAllowRemove(cmd.Context(), args, cmd.OutOrStdout())
62		},
63	}
64}
65
66func runAutorouteAllowAdd(ctx context.Context, args []string, out io.Writer) error {
67	handle, err := resolveControlPlane(configPath)
68	if err != nil {
69		return err
70	}
71	defer handle.close()
72	if err := handle.plane.AddAutoRouteAllowedDomain(ctx, args[0]); err != nil {
73		return fmt.Errorf("failed to add auto-route allowed domain: %w", err)
74	}
75	return cliWriteLine(out, cliRenderSuccess("Allowed domain added"))
76}
77
78func runAutorouteAllowList(ctx context.Context, out io.Writer, jsonOut bool) error {
79	handle, err := resolveControlPlane(configPath)
80	if err != nil {
81		return err
82	}
83	defer handle.close()
84	domains, err := handle.plane.GetAutoRouteAllowedDomains(ctx)
85	if err != nil {
86		return fmt.Errorf("failed to list auto-route allowed domains: %w", err)
87	}
88	if jsonOut {
89		return writeJSON(out, map[string]any{"domains": domains})
90	}
91	if len(domains) == 0 {
92		return cliWriteLine(out, cliRenderMuted("No allowed domains configured"))
93	}
94	for _, domain := range domains {
95		if err := cliWriteLine(out, domain); err != nil {
96			return err
97		}
98	}
99	return nil
100}
101
102func runAutorouteAllowRemove(ctx context.Context, args []string, out io.Writer) error {
103	handle, err := resolveControlPlane(configPath)
104	if err != nil {
105		return err
106	}
107	defer handle.close()
108	if err := handle.plane.RemoveAutoRouteAllowedDomain(ctx, args[0]); err != nil {
109		return fmt.Errorf("failed to remove auto-route allowed domain: %w", err)
110	}
111	return cliWriteLine(out, cliRenderSuccess("Allowed domain removed"))
112}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 106

↑↓ moveenter openesc close