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

Function newDefaultsUpdateCommand

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

Source from the content-addressed store, hash-verified

166}
167
168func newDefaultsUpdateCommand() *cobra.Command {
169 var scope, repo, org, enterprise string
170 var yes, dryRun bool
171
172 cmd := &cobra.Command{
173 Use: "update [file]",
174 Short: "Upload defaults from a YAML file",
175 Long: `Upload compiler defaults from a YAML file.
176
177When [file] is omitted, the command reads from file.yml.
178
179Scope and flag behavior:
180- --scope is required (repo|org|ent).
181- repo scope uses --repo owner/repo, or the current repository when --repo is omitted.
182- org scope uses --org when provided; otherwise it infers the organization from --repo (or the current repository).
183- ent scope requires --enterprise <slug>.
184- --dry-run previews planned changes and exits without applying updates.
185- --yes skips the confirmation prompt for real updates; it has no effect with --dry-run.`,
186 Args: cobra.MaximumNArgs(1),
187 RunE: func(cmd *cobra.Command, args []string) error {
188 inputFile := "file.yml"
189 if len(args) == 1 {
190 inputFile = args[0]
191 }
192 target, err := resolveDefaultsTarget(scope, repo, org, enterprise, true)
193 if err != nil {
194 return err
195 }
196 return defaultsUpdateFromFile(target, inputFile, yes, dryRun)
197 },
198 }
199
200 cmd.Flags().StringVar(&scope, "scope", "", "Variable scope (repo|org|ent)")
201 cmd.Flags().StringVarP(&repo, "repo", "r", "", "Target repository in owner/repo format. When omitted, defaults to current repository")
202 cmd.Flags().StringVar(&org, "org", "", "Target organization (required for --scope org unless inferable from --repo/current repo)")
203 cmd.Flags().StringVar(&enterprise, "enterprise", "", "Target enterprise slug (required for --scope ent)")
204 cmd.Flags().BoolVarP(&yes, "yes", "y", false, "Skip confirmation prompt")
205 cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Preview updates without applying any changes")
206 _ = cmd.MarkFlagRequired("scope")
207 return cmd
208}
209
210func defaultsGetToFile(target defaultsTarget, outputFile string) error {
211 envCmdLog.Printf("Getting defaults to file: scope=%s, output=%s", target.scope, outputFile)

Callers 1

NewEnvCommandFunction · 0.85

Calls 2

resolveDefaultsTargetFunction · 0.85
defaultsUpdateFromFileFunction · 0.85

Tested by

no test coverage detected