Browse Source

made default save loc in the users home dir

aeth 1 month ago
parent
commit
5739d64c7e
3 changed files with 8 additions and 3 deletions
  1. 1 1
      cmd/main.go
  2. 5 0
      pkg/savestate.go
  3. 2 2
      pkg/userinterface.go

+ 1 - 1
cmd/main.go

@@ -12,7 +12,7 @@ import (
 func main() {
 	addtask := flag.Bool("add", false, "add a task to the shelf")
 	flag.Parse()
-	shelf := itashi.NewFilesystemShelf(itashi.FS_SAVE_LOCATION)
+	shelf := itashi.NewFilesystemShelf(itashi.GetDefualtSave())
 	if *addtask {
 		itashi.AddTaskPrompt(shelf)
 		os.Exit(0)

+ 5 - 0
pkg/savestate.go

@@ -2,6 +2,7 @@ package itashi
 
 import (
 	"bytes"
+	"fmt"
 	"log"
 	"os"
 	"strconv"
@@ -27,6 +28,10 @@ type Task struct {
 	Priority int
 }
 
+func GetDefualtSave() string {
+	return fmt.Sprintf("%s/.config/itashi/todo.ta", os.Getenv("HOME"))
+}
+
 // lets make Task implement the tea.Model interface
 func (t Task) Init() tea.Cmd {
 	return nil

+ 2 - 2
pkg/userinterface.go

@@ -207,7 +207,7 @@ type model struct {
 }
 
 func InitialModel() model {
-	shelf := NewFilesystemShelf(FS_SAVE_LOCATION)
+	shelf := NewFilesystemShelf(GetDefualtSave())
 	return model{
 		choices:  GetTaskNames(shelf.GetAll()),
 		selected: make(map[int]struct{}),
@@ -268,7 +268,7 @@ func (m model) View() string {
 	if err != nil {
 		log.Fatal("Couldnt parse the header template.. sorry. ", err)
 	}
-	shelf := NewFilesystemShelf(FS_SAVE_LOCATION)
+	shelf := NewFilesystemShelf(GetDefualtSave())
 
 	s := getHeader(UserImplementation{}, tmpl)