add args to exec
This commit is contained in:
parent
e6f9779e49
commit
85d102204f
2 changed files with 23 additions and 1 deletions
|
|
@ -113,7 +113,11 @@ func (p execPlugin) Layout(ctx context.Context, g *d2graph.Graph) error {
|
|||
return err
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, p.path, "layout")
|
||||
args := []string{"layout"}
|
||||
for k, v := range p.opts {
|
||||
args = append(args, k, v)
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, p.path, args...)
|
||||
|
||||
buffer := bytes.Buffer{}
|
||||
buffer.Write(graphBytes)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ func Serve(p Plugin) xmain.RunFunc {
|
|||
switch subcmd {
|
||||
case "info":
|
||||
return info(ctx, p, ms)
|
||||
case "flags":
|
||||
return flags(ctx, p, ms)
|
||||
case "layout":
|
||||
return layout(ctx, p, ms)
|
||||
case "postprocess":
|
||||
|
|
@ -64,6 +66,22 @@ func info(ctx context.Context, p Plugin, ms *xmain.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func flags(ctx context.Context, p Plugin, ms *xmain.State) error {
|
||||
flags, err := p.Flags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = ms.Stdout.Write(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func layout(ctx context.Context, p Plugin, ms *xmain.State) error {
|
||||
in, err := io.ReadAll(ms.Stdin)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue