alecthomas / alecthomas/kong

existingdir with default validated and stops program run on unused-subcommand

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

Descrizione

# Summary

If you have multiple subcommands, which have constrained arguments (e.g. `existingdir` with default
values) those constraints must pass even if the subcommand is not invoked.

I would expect uninvoked subcommands to *NOT* interrupt program run.

# Kong Code

```go
type Options struct {
Cmd1 Subcommand1 `cmd:""`
Cmd2 Subcommand2 `cmd:""`
}

type Subcommand1 struct {
Dir1 string `group:"dir" help:"get a directory" type:"existingdir" default:"dir1"`
}

type Subcommand2 struct {
Dir2 string `group:"dir" help:"get a directory" type:"existingdir" default:"dir2"`
}

```

# Output

```shell
$ mkdir -p dir1 && go run main.go cmd-1 --dir-1 dir1
--dir-2: stat /Users/dsasser/personal/kong-bug-demo/dir2: no such file or directory
exit status 1
```

# Expected Output

The expectation is that the program would run, as the constraints on the operable subcommand have been satisfied.

Note that if the `default` value is left off the parameters in the subcommands, the program runs as expected.

# Running example

A running example of this problem can be found [here](https://github.com/deweysasser/kong-bug-demo.git)

# Notes

This may be related to #190

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.