Merge pull request #1271 from alixander/layoutplugin-panic
fix reparsing flags
This commit is contained in:
commit
6d2613effb
3 changed files with 25 additions and 14 deletions
|
|
@ -19,3 +19,4 @@
|
|||
- Fixes rare panic exporting to gifs [#1257](https://github.com/terrastruct/d2/pull/1257)
|
||||
- Fixes bad performance in large grid diagrams [#1263](https://github.com/terrastruct/d2/pull/1263)
|
||||
- Fixes bug in ELK when container has ID "root" [#1268](https://github.com/terrastruct/d2/pull/1268)
|
||||
- Fixes edge case panic with invalid CLI arguments [#1271](https://github.com/terrastruct/d2/pull/1271)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
// Also see execPlugin in exec.go for the d2 binary plugin protocol.
|
||||
func Serve(p Plugin) xmain.RunFunc {
|
||||
return func(ctx context.Context, ms *xmain.State) (err error) {
|
||||
if !ms.Opts.Flags.Parsed() {
|
||||
fs, err := p.Flags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -36,6 +37,7 @@ func Serve(p Plugin) xmain.RunFunc {
|
|||
// At some point we want to write a friendly help.
|
||||
return info(ctx, p, ms)
|
||||
}
|
||||
}
|
||||
|
||||
if len(ms.Opts.Flags.Args()) < 1 {
|
||||
return xmain.UsageErrorf("expected first argument to be subcmd name")
|
||||
|
|
|
|||
|
|
@ -58,6 +58,14 @@ func TestCLI_E2E(t *testing.T) {
|
|||
assert.Testdata(t, ".svg", svg)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "flags-panic",
|
||||
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
|
||||
writeFile(t, dir, "hello-world.d2", `x -> y`)
|
||||
err := runTestMain(t, ctx, dir, env, "layout", "dagre", "--dagre-nodesep", "50", "hello-world.d2")
|
||||
assert.ErrorString(t, err, `failed to wait xmain test: e2etests-cli/d2: failed to unmarshal input to graph: `)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty-layer",
|
||||
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue