MCPcopy Create free account
hub / github.com/github/gh-aw / newDefaultsGetCommand

Function newDefaultsGetCommand

pkg/cli/env_command.go:132–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132func newDefaultsGetCommand() *cobra.Command {
133 var scope, repo, org, enterprise string
134
135 cmd := &cobra.Command{
136 Use: "get [file]",
137 Short: "Download defaults into a YAML file",
138 Long: `Download compiler defaults into a YAML file.
139
140When [file] is omitted, the command writes to file.yml.
141
142Scope resolution:
143- --scope defaults to repo.
144- repo scope uses --repo owner/repo, or the current repository when --repo is omitted.
145- org scope uses --org when provided; otherwise it infers the organization from --repo (or the current repository).
146- ent scope requires --enterprise <slug>.`,
147 Args: cobra.MaximumNArgs(1),
148 RunE: func(cmd *cobra.Command, args []string) error {
149 outputFile := "file.yml"
150 if len(args) == 1 {
151 outputFile = args[0]
152 }
153 target, err := resolveDefaultsTarget(scope, repo, org, enterprise, false)
154 if err != nil {
155 return err
156 }
157 return defaultsGetToFile(target, outputFile)
158 },
159 }
160
161 cmd.Flags().StringVar(&scope, "scope", "", "Variable scope (repo|org|ent). Defaults to repo")
162 cmd.Flags().StringVarP(&repo, "repo", "r", "", "Target repository in owner/repo format. When omitted, defaults to current repository")
163 cmd.Flags().StringVar(&org, "org", "", "Target organization (required for --scope org unless inferable from --repo/current repo)")
164 cmd.Flags().StringVar(&enterprise, "enterprise", "", "Target enterprise slug (required for --scope ent)")
165 return cmd
166}
167
168func newDefaultsUpdateCommand() *cobra.Command {
169 var scope, repo, org, enterprise string

Callers 1

NewEnvCommandFunction · 0.85

Calls 2

resolveDefaultsTargetFunction · 0.85
defaultsGetToFileFunction · 0.85

Tested by

no test coverage detected