mirror of Walter-Sparrow / lunar-tear
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Enhance wizard CLI with support for --prefer-saved flag to skip confirmation prompts and reuse saved configurations

+30 -9
+13 -6
README.md
··· 24 24 go run ./cmd/wizard 25 25 ``` 26 26 27 - Your choices are saved so next time you just press Enter to relaunch with the same settings. 27 + Your choices are saved so next time you just press Enter to relaunch with the same settings. To skip the confirmation prompt entirely (useful for scripts or quick relaunches), pass `--prefer-saved`: 28 + 29 + ```bash 30 + go run ./cmd/wizard --prefer-saved 31 + ``` 32 + 33 + If no saved config exists, the flag prints an error and exits. 28 34 29 35 #### Custom Ports 30 36 ··· 34 40 go run ./cmd/wizard --grpc-port 9003 --cdn-port 9080 35 41 ``` 36 42 37 - | Flag | Default | Description | 38 - | ------------- | ------- | ---------------- | 39 - | `--grpc-port` | `8003` | gRPC server port | 40 - | `--cdn-port` | `8080` | CDN server port | 41 - | `--auth-port` | `3000` | Auth server port | 43 + | Flag | Default | Description | 44 + | ---------------- | ------- | ---------------------------------- | 45 + | `--prefer-saved` | `false` | Reuse saved config without prompting | 46 + | `--grpc-port` | `8003` | gRPC server port | 47 + | `--cdn-port` | `8080` | CDN server port | 48 + | `--auth-port` | `3000` | Auth server port | 42 49 43 50 Custom ports are saved to `.wizard.json` alongside your other settings. On the next run the saved ports are reused automatically — no need to pass the flags again. If you later pass different port flags, the wizard warns you that the ports changed and asks for confirmation before continuing. 44 51
+17 -3
server/cmd/wizard/main.go
··· 55 55 56 56 func main() { 57 57 setupOnly := flag.Bool("setup-only", false, "show patching instructions and exit without building or launching") 58 + preferSaved := flag.Bool("prefer-saved", false, "reuse saved config without prompting") 58 59 grpcPort := flag.Int("grpc-port", defaultGRPCPort, "gRPC server port") 59 60 cdnPort := flag.Int("cdn-port", defaultCDNPort, "CDN server port") 60 61 authPort := flag.Int("auth-port", defaultAuthPort, "auth server port") ··· 77 78 downloadDeps() 78 79 } 79 80 80 - ip, cfg, firstRun := resolveIP() 81 + ip, cfg, firstRun := resolveIP(*preferSaved) 81 82 82 83 p := resolvePorts(flagSet, *grpcPort, *cdnPort, *authPort, cfg) 83 84 savedPorts := portsFromConfig(cfg) ··· 311 312 } 312 313 } 313 314 314 - func resolveIP() (string, config, bool) { 315 - if cfg, err := loadConfig(); err == nil { 315 + func resolveIP(preferSaved bool) (string, config, bool) { 316 + cfg, err := loadConfig() 317 + if err == nil { 318 + if preferSaved { 319 + if isLANBased(cfg) { 320 + if ip, updated, ok := recheckLANIP(cfg); ok { 321 + return ip, updated, false 322 + } 323 + } 324 + return cfg.IP, cfg, false 325 + } 326 + 316 327 ip, cfg, done := handleSavedConfig(cfg) 317 328 if done { 318 329 return ip, cfg, false 319 330 } 331 + } else if preferSaved { 332 + fmt.Fprintln(os.Stderr, " --prefer-saved: no saved config found; run without the flag first.") 333 + os.Exit(1) 320 334 } 321 335 322 336 ip, cfg := runWizard()