diff --git a/cmd/diary/main.go b/cmd/diary/main.go new file mode 100644 index 0000000..904d279 --- /dev/null +++ b/cmd/diary/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "errors" + "isthisnagee.com/tools/eng-log/db" + "log" + "os" + "path" +) + +func main() { + + home_dir, err := os.UserHomeDir() + if err != nil { + log.Fatal(err.Error()) + } + + var db_path = path.Join(home_dir, ".dev-log.sql") + + if _, err := os.Stat(db_path); errors.Is(err, os.ErrNotExist) { + _, err := os.Create(db_path) + if err != nil { + log.Fatal(err.Error()) + } + } + + _, err = db.Init(db_path) + if err != nil { + log.Fatal(err.Error()) + } +} diff --git a/log.go b/db/db.go similarity index 78% rename from log.go rename to db/db.go index f21c80f..1c3ad5b 100644 --- a/log.go +++ b/db/db.go @@ -1,4 +1,4 @@ -package main +package db import ( "context" @@ -6,9 +6,6 @@ import ( "errors" "fmt" _ "github.com/mattn/go-sqlite3" - "log" - "os" - "path" ) var __version = 1 @@ -71,29 +68,3 @@ func Init(db_location string) (*LogCtx, error) { return &LogCtx{db, version}, nil } - -func (db *LogCtx) AddEntry(title string) int { - return 1 -} - -func main() { - - home_dir, err := os.UserHomeDir() - if err != nil { - log.Fatal(err.Error()) - } - - var db_path = path.Join(home_dir, ".dev-log.sql") - - if _, err := os.Stat(db_path); errors.Is(err, os.ErrNotExist) { - _, err := os.Create(db_path) - if err != nil { - log.Fatal(err.Error()) - } - } - - _, err = Init(db_path) - if err != nil { - log.Fatal(err.Error()) - } -} diff --git a/log_test.go b/db/db_test.go similarity index 99% rename from log_test.go rename to db/db_test.go index 811663d..b5dc306 100644 --- a/log_test.go +++ b/db/db_test.go @@ -1,4 +1,4 @@ -package main +package db import ( "database/sql"