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
11 changes: 8 additions & 3 deletions cmd/pom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ func main() {
}
}

const (
profileDefault = "default"
profilePessimistic = "pessimistic"
)

func run(args []string, stdin io.Reader, stdout io.Writer) error {
fs := flag.NewFlagSet("pom", flag.ContinueOnError)
repo := fs.String("repo", pom.DefaultRepoURL, "Maven repository base URL")
file := fs.String("f", "", "read root POM from file (use - for stdin)")
profiles := fs.String("profiles", "default", "profile mode: default | pessimistic | id1,id2,...")
profiles := fs.String("profiles", profileDefault, "profile mode: default | pessimistic | id1,id2,...")
follow := fs.Bool("relocate", false, "follow <relocation> and resolve the target")
asXML := fs.Bool("xml", false, "emit a minimal effective-pom XML instead of JSON")
timeout := fs.Duration("timeout", defaultTimeout, "overall timeout")
Expand Down Expand Up @@ -183,9 +188,9 @@ func followRelocation(ctx context.Context, r *pom.Resolver, ep *pom.EffectivePOM

func parseProfiles(s string) pom.ProfileActivation {
switch s {
case "", "default":
case "", profileDefault:
return pom.ProfileActivation{Mode: pom.OnlyDefault}
case "pessimistic", "all":
case profilePessimistic, "all":
return pom.ProfileActivation{Mode: pom.Pessimistic}
default:
return pom.ProfileActivation{Mode: pom.Explicit, IDs: strings.Split(s, ",")}
Expand Down
12 changes: 6 additions & 6 deletions cmd/pom/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,20 @@ func TestParseProfiles(t *testing.T) {
in string
want string
}{
{"default", "default"},
{"", "default"},
{"pessimistic", "pessimistic"},
{"all", "pessimistic"},
{profileDefault, profileDefault},
{"", profileDefault},
{profilePessimistic, profilePessimistic},
{"all", profilePessimistic},
{"a,b", "explicit"},
}
for _, tt := range tests {
got := parseProfiles(tt.in)
var name string
switch got.Mode {
case 0:
name = "default"
name = profileDefault
case 1:
name = "pessimistic"
name = profilePessimistic
default:
name = "explicit"
}
Expand Down