diff --git a/cmd/init.go b/cmd/init.go index 6a75cb6..f19e0fb 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -43,17 +43,17 @@ func noteInit(cmd *cobra.Command, args []string) { // the option from the config file. viper.Set("db", dbF) - mkdir(filepath.Dir(configPathArg)) - mkdir(filepath.Dir(dbF)) - - if !forceArg && exists(configPathArg) { - fmt.Fprintln(os.Stderr, "Config file already exists") - forceInform = true - } else { - fmt.Printf("Writing config file: %v\n", configPathArg) - err := viper.WriteConfig() - if err != nil { - quitError("writing config", err) + if !dbOnlyArg { + if !forceArg && exists(configPathArg) { + fmt.Fprintln(os.Stderr, "Config file already exists") + forceInform = true + } else { + mkdir(filepath.Dir(configPathArg)) + err := viper.WriteConfig() + if err != nil { + quitError("writing config", err) + } + fmt.Printf("Wrote config file: %v\n", configPathArg) } } @@ -61,10 +61,11 @@ func noteInit(cmd *cobra.Command, args []string) { fmt.Fprintln(os.Stderr, "Storage file already exists") forceInform = true } else { - fmt.Printf("Create initial db: %v\n", dbF) + mkdir(filepath.Dir(dbF)) if _, err := db.CreateDb(dbF); err != nil { quitError("creating db", err) } + fmt.Printf("Created db: %v\n", dbF) } if forceInform { diff --git a/cmd/root.go b/cmd/root.go index e1c3203..4893349 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -296,7 +296,8 @@ Files will only be imported once (per run), no checks for duplicate notes are ma storagePathArg string // Init argument - forceArg bool + dbOnlyArg bool + forceArg bool // Add arguments fileArg string @@ -364,6 +365,7 @@ func init() { rootFlags.AddFlagSet(selectFlagSet) initFlags := initCmd.Flags() + initFlags.BoolVar(&dbOnlyArg, "db-only", false, "only initialize a database file") initFlags.BoolVar(&forceArg, "force", false, "determines if existing files will be overwritten") addFlags := addCmd.Flags()