Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log"
"os"

"github.com/aadam-ali/second-brain-cli/config"
"github.com/spf13/cobra"
)

Expand All @@ -26,6 +27,12 @@ var rootCmd = &cobra.Command{
// Execute handles the execution of the provided command
// this may be the root command or any of it's children
func Execute() {
cfg := config.GetConfig()

os.MkdirAll(cfg.RootDir, os.ModePerm)
os.MkdirAll(cfg.InboxDir, os.ModePerm)
os.MkdirAll(cfg.JournalDir, os.ModePerm)

if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Configuration struct {
func GetConfig() Configuration {
userHomeDir, _ := os.UserHomeDir()

rootDir := getEnv("SB", fmt.Sprintf("%s/SecondBrain", userHomeDir))
rootDir := getEnv("SB", fmt.Sprintf("%s/notes", userHomeDir))
inboxDir := getEnv("SB_INBOX", fmt.Sprintf("%s/inbox", rootDir))
journalDir := getEnv("SB_JOURNAL", fmt.Sprintf("%s/journal", rootDir))

Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestGetConfigDefaultValues(t *testing.T) {

os.Clearenv()
os.Setenv("HOME", "/home/test")
rootDir := "/home/test/SecondBrain"
rootDir := "/home/test/notes"

want := Configuration{
RootDir: rootDir,
Expand Down