~porcellis/t

4a2f79c2a59204e877d10648bad7e5e4110614de — Pedro Lucas Porcellis 3 months ago 2aff3bc
create: sanitize note name
1 files changed, 3 insertions(+), 2 deletions(-)

M commands/create.go
M commands/create.go => commands/create.go +3 -2
@@ 6,15 6,17 @@ import (
	"git.sr.ht/~porcellis/t/models"
	"os"
	"path"
	"strings"
	"time"
)

func CreateWithName(config config.TConfig, title string) (models.Note, error) {
func CreateWithName(config config.TConfig, originalTitle string) (models.Note, error) {
	var (
		err  error
		note models.Note
	)

	title := strings.Replace(originalTitle, " ", "-", -1)
	file, err := os.Create(path.Join(config.BasePath, fmt.Sprintf("%s.md", title)))

	stat, _ := file.Stat()


@@ 22,7 24,6 @@ func CreateWithName(config config.TConfig, title string) (models.Note, error) {
	note = models.Note{Name: stat.Name(), Path: path.Join(config.BasePath, stat.Name()), ModTime: stat.ModTime()}

	return note, err

}

func Create(config config.TConfig) (models.Note, error) {