t

commit 2a23fee8363f08ad08b4929f205680f9ee4f28e9

Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>

Use Aurora to display ANSI and display a small preview

 commands/list.go | 22 +++++++++++++++++++---
 go.mod | 5 ++++-
 go.sum | 5 +++++
 main.go | 6 +++---


diff --git a/commands/list.go b/commands/list.go
index a754974119be83f79806b642ddba7e99b6b36206..ae58f5cd872ed9a652753dad61e4f563c5741966 100644
--- a/commands/list.go
+++ b/commands/list.go
@@ -4,11 +4,19 @@ import (
 	"fmt"
 	"git.sr.ht/~porcellis/t/config"
 	"git.sr.ht/~porcellis/t/models"
+	. "github.com/logrusorgru/aurora"
 	"io/ioutil"
+	"os"
 	"path"
 	"sort"
 )
 
+func check(e error) {
+	if e != nil {
+		panic(e)
+	}
+}
+
 func List(config config.TConfig) error {
 	var (
 		err error
@@ -20,10 +28,18 @@ 	if err != nil {
 		return err
 	}
 
-	fmt.Println("\n \t Your notes")
+	fmt.Println(Bold("\n \t Your notes\n\n"))
 
-	for index, note := range notes {
-		fmt.Printf("|#%-6d|\t%6s\t|%6s|\n", index, note.Title(), note.UpdatedAt())
+	for _, note := range notes {
+		fmt.Printf("%s (%s)\n", Bold(note.Title()), Faint(note.UpdatedAt()).BrightYellow())
+
+		f, err := os.Open(note.Path)
+		check(err)
+
+		b1 := make([]byte, 35)
+		n1, err := f.Read(b1)
+		check(err)
+		fmt.Printf("%s\n\n", string(b1[:n1]))
 	}
 
 	return err




diff --git a/go.mod b/go.mod
index b2625a624b2e6d54a7c05f20d6a4e0888b245ada..8110271f9fc5d0f776682b1d817b87a13935c3e1 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,7 @@ module git.sr.ht/~porcellis/t
 
 go 1.13
 
-require git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b
+require (
+	git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b
+	github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
+)




diff --git a/go.sum b/go.sum
index 43bebffe09012bd543cbf6e1b49ca5810ac03704..565b69689645aa5b704ec9934e99e61ab61fcabe 100644
--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,11 @@
 git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b h1:da5JBQ6dcW14aWnEf/pFRIMV2PsqTQEWmR+V2sw5oxU=
 git.sr.ht/~sircmpwn/getopt v0.0.0-20190808004552-daaf1274538b/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23 h1:Wp7NjqGKGN9te9N/rvXYRhlVcrulGdxnz8zadXWs7fc=
+github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=




diff --git a/main.go b/main.go
index b0e03f5189689b2abb4b6767896cbed8388a8336..981efc8df19c3931594e4fbcf1a59e6dd6c89122 100644
--- a/main.go
+++ b/main.go
@@ -32,7 +32,6 @@ 			println("Edit specified")
 		case 'l':
 			commands.List(*c)
 		case 'c':
-			println("On Create")
 			println(opt.Value)
 
 			var note models.Note
@@ -52,9 +51,10 @@ 			if err != nil {
 				panic("We could not invoke your $EDITOR")
 			}
 
-			// We should call sync
+			// We should call commit
+			// commands.Commit()
+
 			// commands.Sync()
-
 			println("Note created", note.Name)
 		case 'd':
 			println("Delete specified")