setCompressionProfile flips the live layer's aggressiveness profile and mirrors it to the env var so a rebuilt layer (e.g. the gateway) inherits it.
(profileStr string)
| 104 | // setCompressionProfile flips the live layer's aggressiveness profile and |
| 105 | // mirrors it to the env var so a rebuilt layer (e.g. the gateway) inherits it. |
| 106 | func (cli *ChatCLI) setCompressionProfile(profileStr string) { |
| 107 | if cli.compressionLayer == nil { |
| 108 | fmt.Println(colorize(" ❌ "+i18n.T("cfg.compression.unavailable"), ColorRed)) |
| 109 | return |
| 110 | } |
| 111 | p, ok := compress.ParseProfile(strings.ToLower(strings.TrimSpace(profileStr))) |
| 112 | if !ok { |
| 113 | fmt.Println(colorize(" ❌ "+i18n.T("cfg.compression.profile_invalid", profileStr), ColorRed)) |
| 114 | fmt.Println(colorize(" "+i18n.T("cfg.compression.profile_valid"), ColorGray)) |
| 115 | return |
| 116 | } |
| 117 | prev := cli.compressionLayer.Profile() |
| 118 | cli.compressionLayer.SetProfile(p) |
| 119 | _ = os.Setenv("CHATCLI_COMPRESSION_PROFILE", p.String()) |
| 120 | |
| 121 | if prev == p { |
| 122 | fmt.Println(colorize(" ✔ "+i18n.T("cfg.compression.profile_noop", p.String()), ColorGray)) |
| 123 | } else { |
| 124 | fmt.Println(colorize(" ✔ "+i18n.T("cfg.compression.profile_ok", prev.String(), p.String()), ColorGreen)) |
| 125 | } |
| 126 | fmt.Println(colorize(" "+i18n.T("cfg.compression.profile_persist_hint", p.String()), ColorGray)) |
| 127 | } |
| 128 | |
| 129 | // setCompressionThreshold changes the engage threshold (bytes) on the live |
| 130 | // layer and mirrors it to the env var for rebuilt layers. |
no test coverage detected