feat: default login handler in bootstrap

When Hooks.Login is nil, Run() now handles the login command directly
using LoginBitwarden with BinaryName as the service name, removing
the need for glue code in each consumer binary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
thibaud-lclr 2026-05-11 11:37:35 +02:00
parent 6bf9dd1866
commit cd0740c75f

View file

@ -8,6 +8,8 @@ import (
"os"
"sort"
"strings"
"forge.lclr.dev/AI/mcp-framework/secretstore"
)
const (
@ -154,15 +156,25 @@ func Run(ctx context.Context, opts Options) error {
}
if handler == nil {
if command == CommandVersion {
switch command {
case CommandVersion:
if strings.TrimSpace(normalized.Version) == "" {
return ErrVersionRequired
}
_, err := fmt.Fprintln(normalized.Stdout, normalized.Version)
return err
}
case CommandLogin:
_, err := secretstore.LoginBitwarden(secretstore.BitwardenLoginOptions{
ServiceName: normalized.BinaryName,
Stdin: normalized.Stdin,
Stdout: normalized.Stdout,
Stderr: normalized.Stderr,
})
return err
default:
return fmt.Errorf("%w: %s", ErrCommandNotConfigured, command)
}
}
return handler(ctx, Invocation{
Command: command,