bf9395e022
CI / results (push) Blocked by required conditions
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / e2e-live (push) Waiting to run
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / deadcode (push) Waiting to run
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/larksuite/cli/internal/core"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
// GlobalOptions are the root-level flags shared by bootstrap parsing and the
|
|
// actual Cobra command tree. Profile is the parsed --profile value; HideProfile
|
|
// is a build-time policy — when true, --profile stays parseable but is marked
|
|
// hidden from help and shell completion.
|
|
type GlobalOptions struct {
|
|
Profile string
|
|
HideProfile bool
|
|
}
|
|
|
|
// RegisterGlobalFlags registers the root-level persistent flags on fs and
|
|
// applies any visibility policy encoded in opts. Pure function: no disk,
|
|
// network, or environment reads — the caller decides HideProfile.
|
|
func RegisterGlobalFlags(fs *pflag.FlagSet, opts *GlobalOptions) {
|
|
fs.StringVar(&opts.Profile, "profile", "", "use a specific profile")
|
|
if opts.HideProfile {
|
|
_ = fs.MarkHidden("profile")
|
|
}
|
|
}
|
|
|
|
// isSingleAppMode reports whether the on-disk config has at most one app.
|
|
// Missing configs are treated as single-app since --profile is meaningless
|
|
// until at least two profiles exist. Intended for the Execute entry point —
|
|
// buildInternal must not call this directly to stay state-free.
|
|
func isSingleAppMode() bool {
|
|
raw, err := core.LoadMultiAppConfig()
|
|
if err != nil || raw == nil {
|
|
return true
|
|
}
|
|
return len(raw.Apps) <= 1
|
|
}
|