alecthomas / alecthomas/kong

xor isn't supported with enum flags

Aperta
#215 6 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
3.2k
Fork
188
Merge medio
1g 1h
PR unite (30g)
2

Descrizione

I'd like to be able to xor two flags, where one flag is a string with lots of options and another flag is a bool. If the user uses the bool the enum flag should get assigned its default value.

IE this test should pass:

```go

func TestXorEnum(t *testing.T) {
var cli struct {
One string `xor:"a" default:"None" enum:"A,B,C,None"`
Two bool `xor:"a"`
}
p := mustNew(t, &cli)
_, err := p.Parse([]string{"--two"})
require.NoError(t, err)
require.Equal(t, "None", cli.One)
}

```

Today it fails

```
--- FAIL: TestXorEnum (0.00s)
kong_test.go:846:
Error Trace: kong_test.go:846
Error: Received unexpected error:
--one and --two can't be used together
Test: TestXorEnum
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.