MCPcopy Create free account
hub / github.com/diillson/chatcli / setCompressionProfile

Method setCompressionProfile

cli/config_compression_mutate.go:106–127  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
106func (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.

Callers 1

Calls 6

TFunction · 0.92
ParseProfileFunction · 0.92
colorizeFunction · 0.85
ProfileMethod · 0.80
SetProfileMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected