-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflags.go
More file actions
79 lines (72 loc) · 3.13 KB
/
flags.go
File metadata and controls
79 lines (72 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cliflags
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// GetOutputKind returns the effective output kind, giving precedence to --json over --output.
func GetOutputKind(cmd *cobra.Command) string {
if jsonFlag, err := cmd.Root().PersistentFlags().GetBool(JSONFlag); err == nil && jsonFlag {
return "json"
}
return viper.GetString(OutputFlag)
}
// GetFields returns the list of fields to include in JSON output, or nil if not specified.
func GetFields(cmd *cobra.Command) []string {
fields, err := cmd.Root().PersistentFlags().GetStringSlice(FieldsFlag)
if err != nil {
return nil
}
return fields
}
const (
BaseURIDefault = "https://app.launchdarkly.com"
DevStreamURIDefault = "https://stream.launchdarkly.com"
PortDefault = "8765"
AccessTokenFlag = "access-token"
AnalyticsOptOut = "analytics-opt-out"
BaseURIFlag = "base-uri"
CorsEnabledFlag = "cors-enabled"
CorsOriginFlag = "cors-origin"
DataFlag = "data"
DevStreamURIFlag = "dev-stream-uri"
EmailsFlag = "emails"
EnvironmentFlag = "environment"
FieldsFlag = "fields"
FlagFlag = "flag"
JSONFlag = "json"
OutputFlag = "output"
PortFlag = "port"
ProjectFlag = "project"
RoleFlag = "role"
SyncOnceFlag = "sync-once"
AccessTokenFlagDescription = "LaunchDarkly access token with write-level access"
AnalyticsOptOutDescription = "Opt out of analytics tracking"
BaseURIFlagDescription = "LaunchDarkly base URI"
CorsEnabledFlagDescription = "Enable CORS headers for browser-based developer tools (default: false)"
CorsOriginFlagDescription = "Allowed CORS origin. Use '*' for all origins (default: '*')"
DevStreamURIDescription = "Streaming service endpoint that the dev server uses to obtain authoritative flag data. This may be a LaunchDarkly or Relay Proxy endpoint"
EnvironmentFlagDescription = "Default environment key"
FieldsFlagDescription = "Comma-separated list of top-level fields to include in JSON output (e.g., --fields key,name,kind)"
FlagFlagDescription = "Default feature flag key"
JSONFlagDescription = "Output JSON format (shorthand for --output json)"
OutputFlagDescription = "Output format: json or plaintext (default: plaintext in a terminal, json otherwise)"
PortFlagDescription = "Port for the dev server to run on"
ProjectFlagDescription = "Default project key"
SyncOnceFlagDescription = "Only sync new projects. Existing projects will neither be resynced nor have overrides specified by CLI flags applied."
)
func AllFlagsHelp() map[string]string {
return map[string]string{
AccessTokenFlag: AccessTokenFlagDescription,
AnalyticsOptOut: AnalyticsOptOutDescription,
BaseURIFlag: BaseURIFlagDescription,
CorsEnabledFlag: CorsEnabledFlagDescription,
CorsOriginFlag: CorsOriginFlagDescription,
DevStreamURIFlag: DevStreamURIDescription,
EnvironmentFlag: EnvironmentFlagDescription,
FlagFlag: FlagFlagDescription,
OutputFlag: OutputFlagDescription,
PortFlag: PortFlagDescription,
ProjectFlag: ProjectFlagDescription,
SyncOnceFlag: SyncOnceFlagDescription,
}
}