Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions pkg/cli/env_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ func newDefaultsGetCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "get [file]",
Short: "Download defaults into a YAML file",
Args: cobra.MaximumNArgs(1),
Long: `Download compiler defaults into a YAML file.

When [file] is omitted, the command writes to file.yml.

Scope resolution:
- --scope defaults to repo.
- repo scope uses --repo owner/repo, or the current repository when --repo is omitted.
- org scope uses --org when provided; otherwise it infers the organization from --repo (or the current repository).
- ent scope requires --enterprise <slug>.`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
outputFile := "file.yml"
if len(args) == 1 {
Expand Down Expand Up @@ -161,7 +170,18 @@ func newDefaultsUpdateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "update [file]",
Short: "Upload defaults from a YAML file",
Args: cobra.MaximumNArgs(1),
Long: `Upload compiler defaults from a YAML file.

When [file] is omitted, the command reads from file.yml.

Scope and flag behavior:
- --scope is required (repo|org|ent).
- repo scope uses --repo owner/repo, or the current repository when --repo is omitted.
- org scope uses --org when provided; otherwise it infers the organization from --repo (or the current repository).
- ent scope requires --enterprise <slug>.
- --dry-run previews planned changes and exits without applying updates.
- --yes skips the confirmation prompt for real updates; it has no effect with --dry-run.`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
inputFile := "file.yml"
if len(args) == 1 {
Expand Down
13 changes: 12 additions & 1 deletion pkg/cli/env_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ func TestNewEnvCommand(t *testing.T) {
require.NotNil(t, cmd)
assert.Equal(t, "env", cmd.Use)

var updateCmd *cobra.Command
var getCmd, updateCmd *cobra.Command
var hasGet, hasUpdate bool
for _, sub := range cmd.Commands() {
if sub.Name() == "get" {
hasGet = true
getCmd = sub
}
if sub.Name() == "update" {
hasUpdate = true
Expand All @@ -29,7 +30,17 @@ func TestNewEnvCommand(t *testing.T) {
}
assert.True(t, hasGet, "env command should include get subcommand")
assert.True(t, hasUpdate, "env command should include update subcommand")
require.NotNil(t, getCmd)
require.NotNil(t, updateCmd)
assert.NotEmpty(t, getCmd.Long)
assert.Contains(t, getCmd.Long, "file")
assert.Contains(t, getCmd.Long, "scope")
assert.Contains(t, getCmd.Long, "--enterprise")
assert.NotEmpty(t, updateCmd.Long)
assert.Contains(t, updateCmd.Long, "file")
assert.Contains(t, updateCmd.Long, "scope")
assert.Contains(t, updateCmd.Long, "--dry-run")
assert.Contains(t, updateCmd.Long, "--yes")
assert.NotNil(t, updateCmd.Flags().Lookup("yes"))
assert.NotNil(t, updateCmd.Flags().Lookup("dry-run"))
}
Expand Down