Merge pull request #833 from nhooyr/fix-bundled-long-help-8f55
d2plugin: Have each plugin return the correct Type
This commit is contained in:
commit
7c08f51f2b
4 changed files with 7 additions and 7 deletions
|
|
@ -119,6 +119,9 @@ func (p *execPlugin) Info(ctx context.Context) (_ *PluginInfo, err error) {
|
||||||
return nil, fmt.Errorf("failed to unmarshal json: %w", err)
|
return nil, fmt.Errorf("failed to unmarshal json: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info.Type = "binary"
|
||||||
|
info.Path = p.path
|
||||||
|
|
||||||
p.info = &info
|
p.info = &info
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,8 @@ type PluginInfo struct {
|
||||||
ShortHelp string `json:"shortHelp"`
|
ShortHelp string `json:"shortHelp"`
|
||||||
LongHelp string `json:"longHelp"`
|
LongHelp string `json:"longHelp"`
|
||||||
|
|
||||||
// These two are set by ListPlugins and not the plugin itself.
|
// Set to bundled when returning from the plugin.
|
||||||
|
// execPlugin will set to binary when used.
|
||||||
// bundled | binary
|
// bundled | binary
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
// If Type == binary then this contains the absolute path to the binary.
|
// If Type == binary then this contains the absolute path to the binary.
|
||||||
|
|
@ -122,12 +123,6 @@ func ListPluginInfos(ctx context.Context, ps []Plugin) ([]*PluginInfo, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if ep, ok := p.(*execPlugin); ok {
|
|
||||||
info.Type = "binary"
|
|
||||||
info.Path = ep.path
|
|
||||||
} else {
|
|
||||||
info.Type = "bundled"
|
|
||||||
}
|
|
||||||
infoSlice = append(infoSlice, info)
|
infoSlice = append(infoSlice, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ func (p dagrePlugin) Info(ctx context.Context) (*PluginInfo, error) {
|
||||||
|
|
||||||
return &PluginInfo{
|
return &PluginInfo{
|
||||||
Name: "dagre",
|
Name: "dagre",
|
||||||
|
Type: "bundled",
|
||||||
ShortHelp: "The directed graph layout library Dagre",
|
ShortHelp: "The directed graph layout library Dagre",
|
||||||
LongHelp: fmt.Sprintf(`dagre is a directed graph layout library for JavaScript.
|
LongHelp: fmt.Sprintf(`dagre is a directed graph layout library for JavaScript.
|
||||||
See https://d2lang.com/tour/dagre for more.
|
See https://d2lang.com/tour/dagre for more.
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ func (p elkPlugin) Info(ctx context.Context) (*PluginInfo, error) {
|
||||||
}
|
}
|
||||||
return &PluginInfo{
|
return &PluginInfo{
|
||||||
Name: "elk",
|
Name: "elk",
|
||||||
|
Type: "bundled",
|
||||||
ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.",
|
ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.",
|
||||||
LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse.
|
LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse.
|
||||||
Originally written in Java, it has been ported to Javascript and cross-compiled into D2.
|
Originally written in Java, it has been ported to Javascript and cross-compiled into D2.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue