Skip to content

Commit 989b91a

Browse files
committed
feat(cli): make agent handle --expire like pago
Make the option global and respect `PAGO_EXPIRE`.
1 parent ea0666c commit 989b91a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cmd/pago-agent/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ import (
1919

2020
type CLI struct {
2121
// Global options.
22-
Memlock bool `env:"${MemlockEnv}" default:"true" negatable:"" help:"Lock agent memory with mlockall(2) (${env})"`
23-
Socket string `short:"s" env:"${SocketEnv}" default:"${DefaultSocket}" help:"Agent socket path (${env})"`
22+
Expire time.Duration `short:"e" env:"${ExpireEnv}" default:"0" help:"Agent expiration time (Go duration, 0 to disable)"`
23+
Memlock bool `env:"${MemlockEnv}" default:"true" negatable:"" help:"Lock agent memory with mlockall(2) (${env})"`
24+
Socket string `short:"s" env:"${SocketEnv}" default:"${DefaultSocket}" help:"Agent socket path (${env})"`
2425

2526
// Commands.
2627
Run RunCmd `cmd:"" help:"Run the agent process"`
2728
Version VersionCmd `cmd:"" aliases:"v,ver" help:"Print version number and exit"`
2829
}
2930

30-
type RunCmd struct {
31-
Expire time.Duration `short:"e" default:"0" help:"Agent expiration time (Go duration, 0 to disable)"`
32-
}
31+
type RunCmd struct{}
3332

3433
func (cmd *RunCmd) Run(cli *CLI) error {
3534
if cli.Memlock {
@@ -44,7 +43,7 @@ func (cmd *RunCmd) Run(cli *CLI) error {
4443
return fmt.Errorf("failed to create socket directory: %v", err)
4544
}
4645

47-
return agent.Run(cli.Socket, cmd.Expire)
46+
return agent.Run(cli.Socket, cli.Expire)
4847
}
4948

5049
type VersionCmd struct{}
@@ -78,6 +77,7 @@ func main() {
7877
kong.Vars{
7978
"DefaultSocket": defaultSocket,
8079

80+
"ExpireEnv": pago.ExpireEnv,
8181
"MemlockEnv": pago.MemlockEnv,
8282
"SocketEnv": pago.SocketEnv,
8383
},

0 commit comments

Comments
 (0)