@@ -6,43 +6,8 @@ import (
6
6
)
7
7
8
8
func (r * RootCmd ) jail () * serpent.Command {
9
- var config jailcli.Config
10
-
11
- return & serpent.Command {
12
- Use : "jail -- <command>" ,
13
- Short : "Monitor and restrict HTTP/HTTPS requests from processes" ,
14
- Long : `coder jail creates an isolated network environment for the target process,
15
- intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
16
- user-defined rules.
17
-
18
- Examples:
19
- # Allow only requests to github.com
20
- coder jail --allow "github.com" -- curl https://github.com
21
-
22
- # Monitor all requests to specific domains (allow only those)
23
- coder jail --allow "github.com/api/issues/*" --allow "GET,HEAD github.com" -- npm install
24
-
25
- # Block everything by default (implicit)` ,
26
- Options : serpent.OptionSet {
27
- {
28
- Name : "allow" ,
29
- Flag : "allow" ,
30
- Env : "JAIL_ALLOW" ,
31
- Description : "Allow rule (can be specified multiple times). Format: 'pattern' or 'METHOD[,METHOD] pattern'." ,
32
- Value : serpent .StringArrayOf (& config .AllowStrings ),
33
- },
34
- {
35
- Name : "log-level" ,
36
- Flag : "log-level" ,
37
- Env : "JAIL_LOG_LEVEL" ,
38
- Description : "Set log level (error, warn, info, debug)." ,
39
- Default : "warn" ,
40
- Value : serpent .StringOf (& config .LogLevel ),
41
- },
42
- },
43
- Hidden : true ,
44
- Handler : func (inv * serpent.Invocation ) error {
45
- return jailcli .Run (inv .Context (), config , inv .Args )
46
- },
47
- }
9
+ cmd := jailcli .BaseCommand () // Package coder/jail/cli exports a "base command" designed to be integrated as a subcommand.
10
+ cmd .Hidden = true // We want jail to be a hidden command in coder for now.
11
+ cmd .Use += " [args...]" // The base command looks like `jail -- command`. Serpent adds the flags piece, but we need to add the args.
12
+ return cmd
48
13
}
0 commit comments