From ce0f40c125ff838d332c1974c8e505e4be1e409b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 16 Nov 2017 10:08:15 -0500 Subject: more --- read_fastimport.go | 63 ------------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 read_fastimport.go (limited to 'read_fastimport.go') diff --git a/read_fastimport.go b/read_fastimport.go deleted file mode 100644 index abafa4b..0000000 --- a/read_fastimport.go +++ /dev/null @@ -1,63 +0,0 @@ -package libfastimport - -import ( - "git.lukeshu.com/go/libfastimport/textproto" -) - -type UnsupportedCommand string - -func (e UnsupportedCommand) Error() string { - return "Unsupported command: "+string(e) -} - -type Parser struct { - fir *textproto.FIReader - - cmd chan Cmd -} - -func (p *Parser) GetCmd() (Cmd, error) { - for p.cmd == nil { - line, err := p.fir.ReadLine() - if err != nil { - return nil, err - } - err = p.putLine(line) - if err != nil { - return nil, err - } - } - return <-p.cmd, nil -} - -func (p *Parser) putLine(line string) error { - if len(line) < 1 { - return UnsupportedCommand(line) - } - switch line[0] { - case '#': // comment - case 'b': // blob - case 'c': - if len(line) < 2 { - return UnsupportedCommand(line) - } - switch line[1] { - case 'o': // commit - case 'h': // checkpoint - case 'a': // cat-blob - default: - return UnsupportedCommand(line) - } - case 'd': // done - case 'f': // feature - case 'g': // get-mark - case 'l': // ls - case 'o': // option - case 'p': // progress - case 'r': // reset - case 't': // tag - default: - return UnsupportedCommand(line) - } - return nil // TODO -} -- cgit v1.2.3