This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plan/action.go
Andrea Luzzardi ae4e61aaa1 dagger do: Improve help message
- Only print first line of comment
- Add "Available Options" section header

Fixes #1777

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2022-03-11 12:55:03 -08:00

34 lines
567 B
Go

package plan
import (
"cuelang.org/go/cue"
)
type Action struct {
Name string
Hidden bool
Path cue.Path
Documentation string
Children []*Action
}
func (a *Action) AddChild(c *Action) {
a.Children = append(a.Children, c)
}
func (a *Action) FindByPath(path cue.Path) *Action {
queue := []*Action{a}
for len(queue) > 0 {
nextUp := queue[0]
queue = queue[1:]
if nextUp.Path.String() == path.String() {
return nextUp
}
if len(nextUp.Children) > 0 {
queue = append(queue, nextUp.Children...)
}
}
return nil
}