feat(cli): support app_url in CLI config (#186)
* feat(cli): support app_url in CLI config for browser login The login flow opens the frontend URL for browser-based auth, but previously app_url could only be set via environment variables. Add app_url to CLIConfig so it can be persisted with `multica config set`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(cli): persist app_url to config during browser login Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ce43ff014d
commit
40aa3f6bd9
3 changed files with 11 additions and 2 deletions
|
|
@ -66,6 +66,10 @@ func resolveAppURL() string {
|
|||
return strings.TrimRight(val, "/")
|
||||
}
|
||||
}
|
||||
cfg, err := cli.LoadCLIConfig()
|
||||
if err == nil && cfg.AppURL != "" {
|
||||
return strings.TrimRight(cfg.AppURL, "/")
|
||||
}
|
||||
return "http://localhost:3000"
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +207,7 @@ func runAuthLoginBrowser(cmd *cobra.Command) error {
|
|||
cfg, _ := cli.LoadCLIConfig()
|
||||
cfg.Token = patResp.Token
|
||||
cfg.ServerURL = serverURL
|
||||
cfg.AppURL = appURL
|
||||
if err := cli.SaveCLIConfig(cfg); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ var configShowCmd = &cobra.Command{
|
|||
var configSetCmd = &cobra.Command{
|
||||
Use: "set <key> <value>",
|
||||
Short: "Set a CLI configuration value",
|
||||
Long: "Supported keys: server_url, workspace_id",
|
||||
Long: "Supported keys: server_url, app_url, workspace_id",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: runConfigSet,
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ func runConfigShow(_ *cobra.Command, _ []string) error {
|
|||
path, _ := cli.CLIConfigPath()
|
||||
fmt.Fprintf(os.Stdout, "Config file: %s\n", path)
|
||||
fmt.Fprintf(os.Stdout, "server_url: %s\n", valueOrDefault(cfg.ServerURL, "(not set)"))
|
||||
fmt.Fprintf(os.Stdout, "app_url: %s\n", valueOrDefault(cfg.AppURL, "(not set)"))
|
||||
fmt.Fprintf(os.Stdout, "workspace_id: %s\n", valueOrDefault(cfg.WorkspaceID, "(not set)"))
|
||||
return nil
|
||||
}
|
||||
|
|
@ -58,10 +59,12 @@ func runConfigSet(_ *cobra.Command, args []string) error {
|
|||
switch key {
|
||||
case "server_url":
|
||||
cfg.ServerURL = value
|
||||
case "app_url":
|
||||
cfg.AppURL = value
|
||||
case "workspace_id":
|
||||
cfg.WorkspaceID = value
|
||||
default:
|
||||
return fmt.Errorf("unknown config key %q (supported: server_url, workspace_id)", key)
|
||||
return fmt.Errorf("unknown config key %q (supported: server_url, app_url, workspace_id)", key)
|
||||
}
|
||||
|
||||
if err := cli.SaveCLIConfig(cfg); err != nil {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ type WatchedWorkspace struct {
|
|||
// CLIConfig holds persistent CLI settings.
|
||||
type CLIConfig struct {
|
||||
ServerURL string `json:"server_url,omitempty"`
|
||||
AppURL string `json:"app_url,omitempty"`
|
||||
WorkspaceID string `json:"workspace_id,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
WatchedWorkspaces []WatchedWorkspace `json:"watched_workspaces,omitempty"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue