From eb63e669c020f676a0a8cb35dfa3e2d047995c46 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 16 Nov 2017 16:21:22 -0500 Subject: more --- frontend.go | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/frontend.go b/frontend.go index f8f335d..256ba52 100644 --- a/frontend.go +++ b/frontend.go @@ -154,15 +154,36 @@ func (f *Frontend) parse() error { // ('merge' SP LF)* // (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)* // TODO + continue case strings.HasPrefix(line, "feature "): // 'feature' SP ('=' )? LF - // TODO + str := strings.TrimSuffix(strings.TrimPrefix(line, "feature "), "\n") + eq := strings.IndexByte(str, '=') + if eq < 0 { + f.cmd <- CmdFeature{ + Feature: str, + } + } else { + f.cmd <- CmdFeature{ + Feature: str[:eq], + Argument: str[eq+1:], + } + } case strings.HasPrefix(line, "ls "): // 'ls' SP SP LF - // TODO + sp1 := strings.IndexByte(line, ' ') + sp2 := strings.IndexByte(line[sp1+1:], ' ') + lf := strings.IndexByte(line[sp2+1:], '\n') + if sp1 < 0 || sp2 < 0 || lf < 0 { + return fmt.Errorf("ls: outside of a commit both and are required: %v", line) + } + f.cmd <- CmdLs{ + DataRef: line[sp1+1:sp2], + Path: textproto.PathUnescape(line[sp2+1:lf]), + } case strings.HasPrefix(line, "option "): // 'option' SP