feat(cmd): wire --provider and --base-url flags into CLI (Phase 5) #106
@@ -85,8 +85,9 @@ func main() {
|
|||||||
aicoreResourceGroup := flag.String("aicore-resource-group", envOrDefault("AICORE_RESOURCE_GROUP", "default"), "SAP AI Core resource group (for provider=aicore)")
|
aicoreResourceGroup := flag.String("aicore-resource-group", envOrDefault("AICORE_RESOURCE_GROUP", "default"), "SAP AI Core resource group (for provider=aicore)")
|
||||||
|
rodin marked this conversation as resolved
|
|||||||
|
|
||||||
// Backward-compatible alias: --gitea-url shares vcsURL's pointer (last flag wins).
|
// Backward-compatible alias: --gitea-url shares vcsURL's pointer (last flag wins).
|
||||||
|
sonnet-review-bot
commented
[MINOR] The **[MINOR]** The `--gitea-url` backward-compatible alias is registered with `flag.StringVar(vcsURL, "gitea-url", *vcsURL, ...)` where `*vcsURL` is the default value captured at the moment of the call — before `flag.Parse()`. This is correct as written because `*vcsURL` is still the default string at that point, but it creates a subtle ordering dependency: if `vcsURL` ever acquired a non-default value between its declaration and this `flag.StringVar` call (e.g., if any code ran between them), the alias would get a stale default. The comment acknowledges this (`Must stay after vcsURL declaration and before flag.Parse()`), but the fragility is worth noting. A cleaner pattern would be `flag.StringVar(vcsURL, "gitea-url", "", "...")` or extracting the default value to a named constant.
|
|||||||
// Shares vcsURL pointer; empty default avoids ordering dependency with vcsURL declaration.
|
// Must use *vcsURL as default: StringVar sets *p=value at registration, so empty
|
||||||
flag.StringVar(vcsURL, "gitea-url", "", "Deprecated: use --vcs-url instead")
|
// string would overwrite the env-resolved value from the --vcs-url declaration.
|
||||||
|
flag.StringVar(vcsURL, "gitea-url", *vcsURL, "Deprecated: use --vcs-url instead")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|||||||
[NIT] The
--gitea-urlalias comment block is long (12 lines) and explains a subtle flag.StringVar trick. Consider extracting the alias registration to a small helper or at minimum shortening the comment to the key invariant:flag.StringVar shares the pointer, so whichever flag is set last wins.The current comment is accurate but its length makes it easy to miss the ORDERING constraint.