diff --git a/cmd/pom/main.go b/cmd/pom/main.go index 76bfd1f..5922b1e 100644 --- a/cmd/pom/main.go +++ b/cmd/pom/main.go @@ -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 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") @@ -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, ",")} diff --git a/cmd/pom/main_test.go b/cmd/pom/main_test.go index 27b3778..e5d89c2 100644 --- a/cmd/pom/main_test.go +++ b/cmd/pom/main_test.go @@ -187,10 +187,10 @@ 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 { @@ -198,9 +198,9 @@ func TestParseProfiles(t *testing.T) { var name string switch got.Mode { case 0: - name = "default" + name = profileDefault case 1: - name = "pessimistic" + name = profilePessimistic default: name = "explicit" }