The secret manager binary was renamed from pass_mgr to secret-mgr. Update all references in CLI code, mode detection, and help text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/config"
|
|
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/mode"
|
|
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/output"
|
|
"git.hangman-lab.top/zhi/HarborForge.Cli/internal/passmgr"
|
|
)
|
|
|
|
// RunConfigURL sets the base URL in the config file.
|
|
func RunConfigURL(url string) {
|
|
if url == "" {
|
|
output.Error("usage: hf config --url <hf-url>")
|
|
}
|
|
if err := config.UpdateURL(url); err != nil {
|
|
output.Errorf("failed to update config: %v", err)
|
|
}
|
|
fmt.Printf("base-url set to %s\n", url)
|
|
}
|
|
|
|
// RunConfigAccMgrToken stores the account-manager token via secret-mgr.
|
|
func RunConfigAccMgrToken(token string) {
|
|
if token == "" {
|
|
output.Error("usage: hf config --acc-mgr-token <token>")
|
|
}
|
|
if !mode.IsPaddedCell() {
|
|
output.Error("--acc-mgr-token can only be set with padded-cell plugin")
|
|
}
|
|
if err := passmgr.SetAccountManagerToken(token); err != nil {
|
|
output.Errorf("failed to store acc-mgr-token: %v", err)
|
|
}
|
|
fmt.Println("account-manager token stored successfully")
|
|
}
|
|
|
|
// RunConfigShow displays the current config.
|
|
func RunConfigShow() {
|
|
cfg, err := config.Load()
|
|
if err != nil {
|
|
output.Errorf("config error: %v", err)
|
|
}
|
|
if output.JSONMode {
|
|
output.PrintJSON(cfg)
|
|
} else {
|
|
p, _ := config.ConfigPath()
|
|
output.PrintKeyValue(
|
|
"base-url", cfg.BaseURL,
|
|
"config-file", p,
|
|
"mode", mode.Detect().String(),
|
|
)
|
|
}
|
|
}
|