summaryrefslogtreecommitdiff
path: root/cmd_comment.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-11-22 14:47:56 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-11-22 14:47:56 -0500
commitf13250e6a926640c4d0ee858f84fcf8036d612aa (patch)
treed50dceaca4c048f7efde241d1af85afccfe406b5 /cmd_comment.go
parentdb24f3cbd10603f852032a95b5983335b6b5aff2 (diff)
ahhh
Diffstat (limited to 'cmd_comment.go')
-rw-r--r--cmd_comment.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/cmd_comment.go b/cmd_comment.go
new file mode 100644
index 0000000..d783ecc
--- /dev/null
+++ b/cmd_comment.go
@@ -0,0 +1,54 @@
+package libfastimport
+
+import (
+ "strconv"
+
+ "git.lukeshu.com/go/libfastimport/textproto"
+)
+
+type CmdComment struct {
+ Comment string
+}
+
+func (c CmdComment) fiCmdClass() cmdClass { return cmdClassComment }
+func (c CmdComment) fiCmdWrite(fiw *textproto.FIWriter) error {
+ return fiw.WriteLine("#" + c.Comment)
+}
+
+type CmdGetMark struct {
+ Mark int
+}
+
+func (c CmdGetMark) fiCmdClass() cmdClass { return cmdClassComment }
+func (c CmdGetMark) fiCmdWrite(fiw *textproto.FIWriter) error {
+ return fiw.WriteLine("get-mark", ":"+strconv.Itoa(c.Mark))
+}
+
+type CmdCatBlob struct {
+ DataRef string
+}
+
+func (c CmdCatBlob) fiCmdClass() cmdClass { return cmdClassComment }
+func (c CmdCatBlob) fiCmdWrite(fiw *textproto.FIWriter) error {
+ return fiw.WriteLine("cat-blob", c.DataRef)
+}
+
+type CmdLs struct {
+ DataRef string // optional if inside of a commit
+ Path textproto.Path
+}
+
+func (c CmdLs) fiCmdClass() cmdClass {
+ if c.DataRef == "" {
+ return cmdClassCommit
+ }
+ return cmdClassComment
+}
+func (c CmdLs) fiCmdWrite(fiw *textproto.FIWriter) error {
+ if c.DataRef == "" {
+ return fiw.WriteLine("ls", c.Path)
+ } else {
+ return fiw.WriteLine("ls", c.DataRef, c.Path)
+ }
+}
+