()
| 130 | } |
| 131 | |
| 132 | func 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 | |
| 140 | When [file] is omitted, the command writes to file.yml. |
| 141 | |
| 142 | Scope 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 | |
| 168 | func newDefaultsUpdateCommand() *cobra.Command { |
| 169 | var scope, repo, org, enterprise string |
no test coverage detected