nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: alecthomas/gometalinter
Pull request #370 (2017-10-09 17:59:43)

Improve error message in the case of an unknown linter
Discovered in #369

When an unknown linter is enabled, raise an error identifying which linter(s) are unknown, rather than failing with:

    WARNING: invalid command ""

Note: linters defined with the --linter flag are not considered unknown and will not fail with this error.

zmb3: Addressed everything except for:

> it wont handle the case where someone defines a linter and forgets to specify a Command. Maybe instead of checking isDefault/isCustom this could call a new function validateLinter() which could check that any required fields are set?

Not sure what you're thinking here @dnephin...can you elaborate?

Patch:
diff --git a/linters.go b/linters.go
index 56d7c05..c523b17 100644
--- a/linters.go
+++ b/linters.go
@@ -182,6 +182,21 @@ func defaultEnabled() []string {
 	return enabled
 }
 
+func validateLinters(linters map[string]*Linter, config *Config) error {
+	var unknownLinters []string
+	for name := range linters {
+		if _, isDefault := defaultLinters[name]; !isDefault {
+			if _, isCustom := config.Linters[name]; !isCustom {
+				unknownLinters = append(unknownLinters, name)
+			}
+		}
+	}
+	if len(unknownLinters) > 0 {
+		return fmt.Errorf("unknown linters: %s", strings.Join(unknownLinters, ", "))
+	}
+	return nil
+}
+
 const vetPattern = `^(?:vet:.*?\.go:\s+(?P<path>.*?\.go):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*))|(?:(?P<path>.*?\.go):(?P<line>\d+):\s*(?P<message>.*))$`
 
 var defaultLinters = map[string]LinterConfig{
diff --git a/main.go b/main.go
index 4e4fa81..4770d95 100644
--- a/main.go
+++ b/main.go
@@ -201,6 +201,9 @@ Severity override map (default is "warning"):
 	paths := resolvePaths(*pathsArg, config.Skip)
 
 	linters := lintersFromConfig(config)
+	err := validateLinters(linters, config)
+	kingpin.FatalIfError(err, "")
+
 	issues, errch := runLinters(linters, paths, config.Concurrency, exclude, include)
 	status := 0
 	if config.JSON {


Test patch:
diff --git a/linters_test.go b/linters_test.go
index 9188187..bf706cd 100644
--- a/linters_test.go
+++ b/linters_test.go
@@ -35,6 +35,24 @@ func TestGetLinterByName(t *testing.T) {
 	assert.Equal(t, config.IsFast, overrideConfig.IsFast)
 }
 
+func TestValidateLinters(t *testing.T) {
+	originalConfig := *config
+	defer func() { config = &originalConfig }()
+
+	config = &Config{
+		Enable: []string{"_dummylinter_"},
+	}
+
+	err := validateLinters(lintersFromConfig(config), config)
+	require.Error(t, err, "expected unknown linter error for _dummylinter_")
+
+	config = &Config{
+		Enable: defaultEnabled(),
+	}
+	err = validateLinters(lintersFromConfig(config), config)
+	require.NoError(t, err)
+}
+
 func functionName(i interface{}) string {
 	return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
 }
Repository: alecthomas/kong
Pull request #142 (2021-02-12 16:52:21)

Add aliases to tree help output
Couldn't find a good example of how other tools format their command aliases, so just went with putting them in parens:

```
Usage: test-app <command>

A test app.

Flags:
  -h, --help    Show context-sensitive help.

Commands:
  one (un,uno)         subcommand one
  - thing              subcommand thing
    - <arg>            argument
  - <other>            subcommand other

  two                  Another subcommand.
  - <three>            Sub-sub-arg.
  - four (for,fore)    Sub-sub-command.

Run "test-app <command> --help" for more information on a command.
```

alecthomas: Looks good, thanks.

Patch:
diff --git a/help.go b/help.go
index 2594946..f08f1a1 100644
--- a/help.go
+++ b/help.go
@@ -474,6 +474,9 @@ func (h *HelpOptions) CommandTree(node *Node, prefix string) (rows [][2]string)
 	switch node.Type {
 	default:
 		nodeName += prefix + node.Name
+		if len(node.Aliases) != 0 {
+			nodeName += fmt.Sprintf(" (%s)", strings.Join(node.Aliases, ","))
+		}
 	case ArgumentNode:
 		nodeName += prefix + "<" + node.Name + ">"
 	}


Test patch:
diff --git a/help_test.go b/help_test.go
index c7d5fe0..0f0f2cb 100644
--- a/help_test.go
+++ b/help_test.go
@@ -245,13 +245,13 @@ func TestHelpTree(t *testing.T) {
 			Other struct {
 				Other string `arg help:"other arg"`
 			} `arg help:"subcommand other"`
-		} `cmd help:"subcommand one" group:"Group A"` // Groups are ignored in trees
+		} `cmd help:"subcommand one" group:"Group A" aliases:"un,uno"` // Groups are ignored in trees
 
 		Two struct {
 			Three threeArg `arg help:"Sub-sub-arg."`
 
 			Four struct {
-			} `cmd help:"Sub-sub-command."`
+			} `cmd help:"Sub-sub-command." aliases:"for,fore"`
 		} `cmd help:"Another subcommand."`
 	}
 
@@ -285,14 +285,14 @@ Flags:
   -h, --help    Show context-sensitive help.
 
 Commands:
-  one          subcommand one
-  - thing      subcommand thing
-    - <arg>    argument
-  - <other>    subcommand other
-
-  two          Another subcommand.
-  - <three>    Sub-sub-arg.
-  - four       Sub-sub-command.
+  one (un,uno)         subcommand one
+  - thing              subcommand thing
+    - <arg>            argument
+  - <other>            subcommand other
+
+  two                  Another subcommand.
+  - <three>            Sub-sub-arg.
+  - four (for,fore)    Sub-sub-command.
 
 Run "test-app <command> --help" for more information on a command.
 `
Repository: alecthomas/kong
Pull request #147 (2021-03-02 03:44:57)

Allow `-` for stdout in path mapper
I passed `-` into a path flag, expecting to be able to special-case it to stdout in my command. Unfortunately it was expanded to an absolute file path and so my command wrote a file called `-` in the current working directory instead.

This can obviously be achieved with a custom mapper, but do you think it would it make sense to allow `-` in the path mapper by default?

alecthomas: Awesome thanks!

Patch:
diff --git a/README.md b/README.md
index 78341a1..47bd1cb 100644
--- a/README.md
+++ b/README.md
@@ -385,8 +385,8 @@ function `NamedMapper(name, mapper)`.
 
 | Name              | Description
 |-------------------|---------------------------------------------------
-| `path`            | A path. ~ expansion is applied.
-| `existingfile`    | An existing file. ~ expansion is applied. `-` is accepted for stdin.
+| `path`            | A path. ~ expansion is applied. `-` is accepted for stdout, and will be passed unaltered.
+| `existingfile`    | An existing file. ~ expansion is applied. `-` is accepted for stdin, and will be passed unaltered.
 | `existingdir`     | An existing directory. ~ expansion is applied.
 | `counter`         | Increment a numeric field. Useful for `-vvv`. Can accept `-s`, `--long` or `--long=N`.
 
diff --git a/mapper.go b/mapper.go
index 183ec09..7eb77fb 100644
--- a/mapper.go
+++ b/mapper.go
@@ -554,7 +554,9 @@ func pathMapper(r *Registry) MapperFunc {
 		if err != nil {
 			return err
 		}
-		path = ExpandPath(path)
+		if path != "-" {
+			path = ExpandPath(path)
+		}
 		target.SetString(path)
 		return nil
 	}


Test patch:
diff --git a/mapper_test.go b/mapper_test.go
index 091322c..a8b84e9 100644
--- a/mapper_test.go
+++ b/mapper_test.go
@@ -378,3 +378,18 @@ func TestFileMapper(t *testing.T) {
 	require.NoError(t, err)
 	require.Equal(t, os.Stdin, cli.File)
 }
+
+func TestPathMapper(t *testing.T) {
+	var cli struct {
+		Path string `arg:"" type:"path"`
+	}
+	p := mustNew(t, &cli)
+
+	_, err := p.Parse([]string{"/an/absolute/path"})
+	require.NoError(t, err)
+	require.Equal(t, "/an/absolute/path", cli.Path)
+
+	_, err = p.Parse([]string{"-"})
+	require.NoError(t, err)
+	require.Equal(t, "-", cli.Path)
+}
Repository: alecthomas/kong
Pull request #191 (2021-08-07 09:31:25)

Add aliases to ALL help output
Add aliases to all help output instead of tree only


Patch:
diff --git a/model.go b/model.go
index e0263d7..aed7c35 100644
--- a/model.go
+++ b/model.go
@@ -204,6 +204,9 @@ func (n *Node) Path() (out string) {
 	switch n.Type {
 	case CommandNode:
 		out += " " + n.Name
+		if len(n.Aliases) > 0 {
+			out += fmt.Sprintf(" (%s)", strings.Join(n.Aliases, ","))
+		}
 	case ArgumentNode:
 		out += " " + "<" + n.Name + ">"
 	default:


Test patch:
diff --git a/help_test.go b/help_test.go
index 97c8d7b..728681e 100644
--- a/help_test.go
+++ b/help_test.go
@@ -342,7 +342,7 @@ Run "test-app <command> --help" for more information on a command.
 			require.NoError(t, err)
 		})
 		require.True(t, exited)
-		expected := `Usage: test-app one <command>
+		expected := `Usage: test-app one (un,uno) <command>
 
 subcommand one
 
@@ -414,7 +414,7 @@ Commands:
   two    Another subcommand.
 
 Group A
-  one    subcommand one
+  one (un,uno)    subcommand one
 
 Run "test-app <command> --help" for more information on a command.
 `
@@ -432,7 +432,7 @@ Run "test-app <command> --help" for more information on a command.
 			require.NoError(t, err)
 		})
 		require.True(t, exited)
-		expected := `Usage: test-app one <command>
+		expected := `Usage: test-app one (un,uno) <command>
 
 subcommand one
 
@@ -440,8 +440,8 @@ Flags:
   -h, --help    Show context-sensitive help.
 
 Group A
-  one thing      subcommand thing
-  one <other>    subcommand other
+  one (un,uno) thing      subcommand thing
+  one (un,uno) <other>    subcommand other
 `
 		if expected != w.String() {
 			t.Errorf("help command returned:\n%v\n\nwant:\n%v", w.String(), expected)
Repository: alecthomas/kong
Pull request #232 (2021-11-17 18:02:26)

Only prepend EnvPrefix if .Env is not empty.
Before this change the EnvPrefix was applied to fields without env
specified, which resulted in strange and confusing help output.

connyay: @alecthomas sorry for being annoying - can this land?

Patch:
diff --git a/build.go b/build.go
index aa5a143..3e8be10 100644
--- a/build.go
+++ b/build.go
@@ -139,7 +139,9 @@ MAIN:
 			name = tag.Prefix + name
 		}
 
-		tag.Env = tag.EnvPrefix + tag.Env
+		if tag.Env != "" {
+			tag.Env = tag.EnvPrefix + tag.Env
+		}
 
 		// Nested structs are either commands or args, unless they implement the Mapper interface.
 		if field.value.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) && k.registry.ForValue(fv) == nil {


Test patch:
diff --git a/help_test.go b/help_test.go
index 875ca1b..d907cc8 100644
--- a/help_test.go
+++ b/help_test.go
@@ -463,7 +463,8 @@ func TestEnvarAutoHelp(t *testing.T) {
 
 func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) {
 	type Anonymous struct {
-		Flag string `env:"FLAG" help:"A flag."`
+		Flag  string `env:"FLAG" help:"A flag."`
+		Other string `help:"A different flag."`
 	}
 	var cli struct {
 		Anonymous `envprefix:"ANON_"`
@@ -473,6 +474,7 @@ func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) {
 	_, err := p.Parse([]string{"--help"})
 	require.NoError(t, err)
 	require.Contains(t, w.String(), "A flag ($ANON_FLAG).")
+	require.Contains(t, w.String(), "A different flag.")
 }
 
 func TestCustomHelpFormatter(t *testing.T) {
Repository: alecthomas/kong
Pull request #234 (2021-11-18 20:51:36)

feat: add support for variable interpolation into env tag key
Fixes issue #233 by enabling support for variable interpolation into the `env` struct tag.

```go
type cli struct {
	EnvFlag string `env:"${myEnv}" help:"Looks at ${myEnv}"`
}

ctx := kong.Parse(&cli{}, kong.Vars{
	"myEnv": "AN_ENV_VAR",
})
```

colin-valentini: @alecthomas can I get a re-stamp? Fixed the tests.

Patch:
diff --git a/kong.go b/kong.go
index 544da2d..70107d5 100644
--- a/kong.go
+++ b/kong.go
@@ -186,16 +186,24 @@ func (k *Kong) interpolateValue(value *Value, vars Vars) (err error) {
 	if varsContributor, ok := value.Mapper.(VarsContributor); ok {
 		vars = vars.CloneWith(varsContributor.Vars(value))
 	}
+
+	updatedVars := map[string]string{
+		"default": value.Default,
+		"enum":    value.Enum,
+	}
 	if value.Default, err = interpolate(value.Default, vars, nil); err != nil {
 		return fmt.Errorf("default value for %s: %s", value.Summary(), err)
 	}
 	if value.Enum, err = interpolate(value.Enum, vars, nil); err != nil {
 		return fmt.Errorf("enum value for %s: %s", value.Summary(), err)
 	}
-	value.Help, err = interpolate(value.Help, vars, map[string]string{
-		"default": value.Default,
-		"enum":    value.Enum,
-	})
+	if value.Flag != nil {
+		if value.Flag.Env, err = interpolate(value.Flag.Env, vars, nil); err != nil {
+			return fmt.Errorf("env value for %s: %s", value.Summary(), err)
+		}
+		updatedVars["env"] = value.Flag.Env
+	}
+	value.Help, err = interpolate(value.Help, vars, updatedVars)
 	if err != nil {
 		return fmt.Errorf("help for %s: %s", value.Summary(), err)
 	}


Test patch:
diff --git a/kong_test.go b/kong_test.go
index f189ee9..646665f 100644
--- a/kong_test.go
+++ b/kong_test.go
@@ -644,6 +644,7 @@ func TestInterpolationIntoModel(t *testing.T) {
 	var cli struct {
 		Flag    string `default:"${default}" help:"Help, I need ${somebody}" enum:"${enum}"`
 		EnumRef string `enum:"a,b" required:"" help:"One of ${enum}"`
+		EnvRef  string `env:"${env}" help:"God ${env}"`
 	}
 	_, err := kong.New(&cli)
 	require.Error(t, err)
@@ -651,14 +652,19 @@ func TestInterpolationIntoModel(t *testing.T) {
 		"default":  "Some default value.",
 		"somebody": "chickens!",
 		"enum":     "a,b,c,d",
+		"env":      "SAVE_THE_QUEEN",
 	})
 	require.NoError(t, err)
+	require.Len(t, p.Model.Flags, 4)
 	flag := p.Model.Flags[1]
 	flag2 := p.Model.Flags[2]
+	flag3 := p.Model.Flags[3]
 	require.Equal(t, "Some default value.", flag.Default)
 	require.Equal(t, "Help, I need chickens!", flag.Help)
 	require.Equal(t, map[string]bool{"a": true, "b": true, "c": true, "d": true}, flag.EnumMap())
 	require.Equal(t, "One of a,b", flag2.Help)
+	require.Equal(t, "SAVE_THE_QUEEN", flag3.Env)
+	require.Equal(t, "God SAVE_THE_QUEEN", flag3.Help)
 }
 
 func TestErrorMissingArgs(t *testing.T) {
Repository: alecthomas/kong
Pull request #236 (2021-11-23 21:33:24)

Fix env var interpolation
Support was added for variable interpolation of the `env` tag in #234, but it did not fully succeed in practice. This PR ensures that the `Env` attribute is updated on both the `value.Flag` and `value.Tag` of the node being interpolated.

Without this change, when `context.Reset` is called, the `env` value on the tag is still something like `${envToBeInterpolated}`, even though the the flag's `env` might be `SOME_ENV_VAR`.


Patch:
diff --git a/kong.go b/kong.go
index 70107d5..45ef8b8 100644
--- a/kong.go
+++ b/kong.go
@@ -201,6 +201,7 @@ func (k *Kong) interpolateValue(value *Value, vars Vars) (err error) {
 		if value.Flag.Env, err = interpolate(value.Flag.Env, vars, nil); err != nil {
 			return fmt.Errorf("env value for %s: %s", value.Summary(), err)
 		}
+		value.Tag.Env = value.Flag.Env
 		updatedVars["env"] = value.Flag.Env
 	}
 	value.Help, err = interpolate(value.Help, vars, updatedVars)


Test patch:
diff --git a/resolver_test.go b/resolver_test.go
index fa83465..81d64f1 100644
--- a/resolver_test.go
+++ b/resolver_test.go
@@ -37,17 +37,26 @@ func TestEnvarsFlagBasic(t *testing.T) {
 	var cli struct {
 		String string `env:"KONG_STRING"`
 		Slice  []int  `env:"KONG_SLICE"`
+		Interp string `env:"${kongInterp}"`
 	}
-	parser, unsetEnvs := newEnvParser(t, &cli, envMap{
-		"KONG_STRING": "bye",
-		"KONG_SLICE":  "5,2,9",
-	})
+	kongInterpEnv := "KONG_INTERP"
+	parser, unsetEnvs := newEnvParser(t, &cli,
+		envMap{
+			"KONG_STRING": "bye",
+			"KONG_SLICE":  "5,2,9",
+			"KONG_INTERP": "foo",
+		},
+		kong.Vars{
+			"kongInterp": kongInterpEnv,
+		},
+	)
 	defer unsetEnvs()
 
 	_, err := parser.Parse([]string{})
 	require.NoError(t, err)
 	require.Equal(t, "bye", cli.String)
 	require.Equal(t, []int{5, 2, 9}, cli.Slice)
+	require.Equal(t, "foo", cli.Interp)
 }
 
 func TestEnvarsFlagOverride(t *testing.T) {
Repository: alecthomas/kong
Pull request #251 (2021-12-12 23:04:36)

Allow more flexible callback return error type
It should not matter what exactly is the return type, only that `return out[0].Interface().(error)` succeeds, no?

alecthomas: Nice, thanks!

Patch:
diff --git a/callbacks.go b/callbacks.go
index f488395..8b78741 100644
--- a/callbacks.go
+++ b/callbacks.go
@@ -79,8 +79,8 @@ func getMethod(value reflect.Value, name string) reflect.Value {
 func callMethod(name string, v, f reflect.Value, bindings bindings) error {
 	in := []reflect.Value{}
 	t := f.Type()
-	if t.NumOut() != 1 || t.Out(0) != callbackReturnSignature {
-		return fmt.Errorf("return value of %T.%s() must be exactly \"error\"", v.Type(), name)
+	if t.NumOut() != 1 || !t.Out(0).Implements(callbackReturnSignature) {
+		return fmt.Errorf("return value of %T.%s() must implement \"error\"", v.Type(), name)
 	}
 	for i := 0; i < t.NumIn(); i++ {
 		pt := t.In(i)


Test patch:
diff --git a/options_test.go b/options_test.go
index c48949e..4d401d9 100644
--- a/options_test.go
+++ b/options_test.go
@@ -42,6 +42,51 @@ func TestBindTo(t *testing.T) {
 	require.Equal(t, "foo", saw)
 }
 
+func TestInvalidCallback(t *testing.T) {
+	type iface interface {
+		Method()
+	}
+
+	saw := ""
+	method := func(i iface) string {
+		saw = string(i.(impl))
+		return saw
+	}
+
+	var cli struct{}
+
+	p, err := New(&cli, BindTo(impl("foo"), (*iface)(nil)))
+	require.NoError(t, err)
+	err = callMethod("method", reflect.ValueOf(impl("??")), reflect.ValueOf(method), p.bindings)
+	require.EqualError(t, err, `return value of *reflect.rtype.method() must implement "error"`)
+}
+
+type zrror struct{}
+
+func (*zrror) Error() string {
+	return "error"
+}
+
+func TestCallbackCustomError(t *testing.T) {
+	type iface interface {
+		Method()
+	}
+
+	saw := ""
+	method := func(i iface) *zrror {
+		saw = string(i.(impl))
+		return nil
+	}
+
+	var cli struct{}
+
+	p, err := New(&cli, BindTo(impl("foo"), (*iface)(nil)))
+	require.NoError(t, err)
+	err = callMethod("method", reflect.ValueOf(impl("??")), reflect.ValueOf(method), p.bindings)
+	require.NoError(t, err)
+	require.Equal(t, "foo", saw)
+}
+
 type bindToProviderCLI struct {
 	Called bool
 	Cmd    bindToProviderCmd `cmd:""`
Repository: alecthomas/kong
Pull request #252 (2021-12-20 22:29:25)

Add ChangeDirFlag to allow changing the current working directory
It allows one to do have something like `git -C` does.

mitar: CI is also passing now.

Patch:
diff --git a/README.md b/README.md
index fa8624c..de49d9b 100644
--- a/README.md
+++ b/README.md
@@ -384,6 +384,21 @@ var CLI struct {
 
 For flags, multiple key+value pairs should be separated by `mapsep:"rune"` tag (defaults to `;`) eg. `--set="key1=value1;key2=value2"`.
 
+## Nested data structure
+
+Kong support a nested data structure as well with `embed:""`. You can combine `embed:""` with `prefix:""`:
+
+```go
+var CLI struct {
+  Logging struct {
+    Level string `enum:"debug,info,warn,error" default:"info"`
+    Type string `enum:"json,console" default:"console"`
+  } `embed:"" prefix:"logging."`
+}
+```
+
+This configures Kong to accept flags `--logging.level` and `--logging.type`.
+
 ## Custom named decoders
 
 Kong includes a number of builtin custom type mappers. These can be used by
diff --git a/util.go b/util.go
index 154aebc..aaf7426 100644
--- a/util.go
+++ b/util.go
@@ -2,6 +2,8 @@ package kong
 
 import (
 	"fmt"
+	"os"
+	"reflect"
 )
 
 // ConfigFlag uses the configured (via kong.Configuration(loader)) configuration loader to load configuration
@@ -33,3 +35,20 @@ func (v VersionFlag) BeforeApply(app *Kong, vars Vars) error {
 	app.Exit(0)
 	return nil
 }
+
+// ChangeDirFlag changes the current working directory to a path specified by a flag
+// early in the parsing process, changing how other flags resolve relative paths.
+//
+// Use this flag to provide a "git -C" like functionality.
+type ChangeDirFlag string
+
+// Decode is used to create a side effect of changing the current working directory.
+func (c ChangeDirFlag) Decode(ctx *DecodeContext) error {
+	var path string
+	err := ctx.Scan.PopValueInto("string", &path)
+	if err != nil {
+		return err
+	}
+	ctx.Value.Target.Set(reflect.ValueOf(ChangeDirFlag(path)))
+	return os.Chdir(path)
+}


Test patch:
diff --git a/util_test.go b/util_test.go
index 358f43d..b4a1666 100644
--- a/util_test.go
+++ b/util_test.go
@@ -3,6 +3,7 @@ package kong
 import (
 	"io/ioutil"
 	"os"
+	"path/filepath"
 	"strings"
 	"testing"
 
@@ -42,3 +43,24 @@ func TestVersionFlag(t *testing.T) {
 	require.Equal(t, "0.1.1", strings.TrimSpace(w.String()))
 	require.Equal(t, 0, called)
 }
+
+func TestChangeDirFlag(t *testing.T) {
+	cwd, err := os.Getwd()
+	require.NoError(t, err)
+	defer os.Chdir(cwd) // nolint: errcheck
+
+	dir := t.TempDir()
+	file := filepath.Join(dir, "out.txt")
+	err = os.WriteFile(file, []byte("foobar"), 0o600)
+	require.NoError(t, err)
+
+	var cli struct {
+		ChangeDir ChangeDirFlag `short:"C"`
+		Path      string        `arg:"" type:"existingfile"`
+	}
+
+	p := Must(&cli)
+	_, err = p.Parse([]string{"-C", dir, "out.txt"})
+	require.NoError(t, err)
+	require.Equal(t, file, cli.Path)
+}
Repository: alecthomas/kong
Pull request #267 (2022-01-29 21:28:04)

fix required/xor behavior w/ > 2 flags
Adds a check for if the xorGroupSet has been satisfied before building the list of missing flags.  Includes the test described in https://github.com/alecthomas/kong/issues/258.


Patch:
diff --git a/context.go b/context.go
index 742bc9b..1e26ff5 100644
--- a/context.go
+++ b/context.go
@@ -793,8 +793,8 @@ func checkMissingFlags(flags []*Flag) error {
 			missing = append(missing, flag.Summary())
 		}
 	}
-	for _, flags := range xorGroup {
-		if len(flags) > 1 {
+	for xor, flags := range xorGroup {
+		if !xorGroupSet[xor] && len(flags) > 1 {
 			missing = append(missing, strings.Join(flags, " or "))
 		}
 	}


Test patch:
diff --git a/kong_test.go b/kong_test.go
index 482775d..e7568b2 100644
--- a/kong_test.go
+++ b/kong_test.go
@@ -932,6 +932,10 @@ func TestXorRequiredMany(t *testing.T) {
 	_, err := p.Parse([]string{"--one"})
 	require.NoError(t, err)
 
+	p = mustNew(t, &cli)
+	_, err = p.Parse([]string{"--three"})
+	require.NoError(t, err)
+
 	p = mustNew(t, &cli)
 	_, err = p.Parse([]string{})
 	require.EqualError(t, err, "missing flags: --one or --two or --three")