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:
parent
6bf9dd1866
commit
cd0740c75f
1 changed files with 14 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue