feat(i18n): add package-level clear handlers
All checks were successful
Security Scan / security (push) Successful in 13s
Test / test (push) Successful in 1m43s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Codex 2026-04-02 02:17:51 +00:00 committed by Virgil
parent 40e00d13f1
commit 18d7ba1f2c
2 changed files with 24 additions and 0 deletions

View file

@ -122,6 +122,13 @@ func PrependHandler(handlers ...KeyHandler) {
}
}
// ClearHandlers removes all handlers from the default service.
func ClearHandlers() {
if svc := Default(); svc != nil {
svc.ClearHandlers()
}
}
func executeIntentTemplate(tmplStr string, data templateData) string {
if tmplStr == "" {
return ""

View file

@ -250,6 +250,23 @@ func TestPrependHandler_Good_Variadic(t *testing.T) {
assert.IsType(t, ProgressHandler{}, handlers[1])
}
func TestClearHandlers_Good(t *testing.T) {
svc, err := New()
require.NoError(t, err)
_ = Init()
prev := Default()
SetDefault(svc)
t.Cleanup(func() {
SetDefault(prev)
})
AddHandler(LabelHandler{})
require.NotEmpty(t, svc.Handlers())
ClearHandlers()
assert.Empty(t, svc.Handlers())
}
// --- executeIntentTemplate ---
func TestExecuteIntentTemplate_Good(t *testing.T) {