MCPcopy Create free account
hub / github.com/dim-an/cod / ParseHelp

Function ParseHelp

parse_doc/parse_help.go:35–69  ·  view source on GitHub ↗
(args []string, help string)

Source from the content-addressed store, hash-verified

33}
34
35func ParseHelp(args []string, help string) (*datastore.HelpPage, error) {
36 if len(args) < 1 {
37 log.Panicf("args cannot be empty")
38 }
39 preparedText, err := makePreparedText(help)
40 if err != nil {
41 return nil, err
42 }
43
44 ctx := parseContext{
45 args: args,
46 text: preparedText,
47 }
48
49 var res *parseResult
50 for idx := range parsers {
51 var err error
52 res, err = parsers[idx].Parse(ctx)
53 if err != nil {
54 log.Printf("Parser %s failed with error %s", parsers[idx].Name(), err)
55 continue
56 }
57 break
58 }
59 if res == nil {
60 panic("expected default parser to parse help successfully")
61 }
62
63 helpPage := datastore.HelpPage{
64 ExecutablePath: args[0],
65 Completions: res.completions,
66 }
67 helpPage.CheckSum = fmt.Sprintf("%x", sha1.Sum([]byte(help)))
68 return &helpPage, nil
69}

Callers 8

runHelpCommandMethod · 0.92
TestParseCatHelpFunction · 0.85
TestParseQuWriteFileHelpFunction · 0.85
TestParseLsHelpFunction · 0.85
TestJavaStyleInclusionFunction · 0.85
TestJavaStyleFunction · 0.85

Calls 3

makePreparedTextFunction · 0.85
ParseMethod · 0.65
NameMethod · 0.65

Tested by 7

TestParseCatHelpFunction · 0.68
TestParseQuWriteFileHelpFunction · 0.68
TestParseLsHelpFunction · 0.68
TestJavaStyleInclusionFunction · 0.68
TestJavaStyleFunction · 0.68