MCPcopy Index your code
hub / github.com/dagger/dagger / MainHelp

Method MainHelp

cmd/dagger/shell_help.go:59–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59func (h *shellCallHandler) MainHelp() string {
60 var doc ShellDoc
61
62 def := h.GetDef(nil)
63
64 // Group functions by source module.
65 type moduleGroup struct {
66 name string // module name ("" for core)
67 short string // module description
68 fns []*modFunction
69 }
70
71 // Collect functions into groups, preserving encounter order.
72 groups := make(map[string]*moduleGroup)
73 var order []string
74
75 constr := def.MainObject.AsObject.Constructor
76 if !constr.HasRequiredArgs() {
77 for _, fn := range def.MainObject.AsFunctionProvider().GetFunctions() {
78 if isHiddenFunction(fn.CmdName()) {
79 continue
80 }
81 src := fn.SourceModuleName
82 g, ok := groups[src]
83 if !ok {
84 g = &moduleGroup{name: src}
85 groups[src] = g
86 order = append(order, src)
87 }
88 g.fns = append(g.fns, fn)
89 }
90 }
91
92 // Fill in module descriptions from dependencies.
93 for _, g := range groups {
94 if g.name == "" {
95 continue
96 }
97 if dep := def.GetDependency(g.name); dep != nil {
98 g.short = dep.Short()
99 } else if g.name == def.Name {
100 g.short = def.Short()
101 }
102 }
103
104 // Emit groups: core first, then entrypoint modules, then dependencies.
105 if g, ok := groups[""]; ok {
106 doc.Add("Available Functions",
107 nameShortWrapped(g.fns, func(f *modFunction) (string, string) {
108 return f.CmdName(), f.Short()
109 }),
110 )
111 }
112
113 // Entrypoint module functions (source module == current module name).
114 if def.HasModule() {
115 if g, ok := groups[def.Name]; ok {
116 title := def.Name

Callers 1

registerCommandsMethod · 0.95

Calls 14

GetDefMethod · 0.95
AddMethod · 0.95
BuiltinsMethod · 0.95
StringMethod · 0.95
isHiddenFunctionFunction · 0.85
nameShortWrappedFunction · 0.85
HasRequiredArgsMethod · 0.80
AsFunctionProviderMethod · 0.80
CmdNameMethod · 0.80
HasModuleMethod · 0.80
GetFunctionsMethod · 0.65
ShortMethod · 0.65

Tested by

no test coverage detected