(rd *proto.Reader)
| 7920 | } |
| 7921 | |
| 7922 | func (cmd *InfoCmd) readReply(rd *proto.Reader) error { |
| 7923 | val, err := rd.ReadString() |
| 7924 | if err != nil { |
| 7925 | return err |
| 7926 | } |
| 7927 | |
| 7928 | section := "" |
| 7929 | scanner := bufio.NewScanner(strings.NewReader(val)) |
| 7930 | for scanner.Scan() { |
| 7931 | line := scanner.Text() |
| 7932 | if strings.HasPrefix(line, "#") { |
| 7933 | if cmd.val == nil { |
| 7934 | cmd.val = make(map[string]map[string]string) |
| 7935 | } |
| 7936 | section = strings.TrimPrefix(line, "# ") |
| 7937 | cmd.val[section] = make(map[string]string) |
| 7938 | } else if line != "" { |
| 7939 | if section == "Modules" { |
| 7940 | moduleRe := regexp.MustCompile(`module:name=(.+?),(.+)$`) |
| 7941 | kv := moduleRe.FindStringSubmatch(line) |
| 7942 | if len(kv) == 3 { |
| 7943 | cmd.val[section][kv[1]] = kv[2] |
| 7944 | } |
| 7945 | } else { |
| 7946 | kv := strings.SplitN(line, ":", 2) |
| 7947 | if len(kv) == 2 { |
| 7948 | cmd.val[section][kv[0]] = kv[1] |
| 7949 | } |
| 7950 | } |
| 7951 | } |
| 7952 | } |
| 7953 | |
| 7954 | return nil |
| 7955 | } |
| 7956 | |
| 7957 | func (cmd *InfoCmd) Item(section, key string) string { |
| 7958 | if cmd.val == nil { |
nothing calls this directly
no test coverage detected