diff --git a/anydb.1 b/anydb.1 index 955aaaa..fd67455 100644 --- a/anydb.1 +++ b/anydb.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== diff --git a/app/db.go b/app/db.go index 6741f35..5dcab0a 100644 --- a/app/db.go +++ b/app/db.go @@ -38,16 +38,16 @@ type DbTag struct { const BucketData string = "data" func New(file string, debug bool) (*DB, error) { - if _, err := os.Stat(filepath.Dir(file)); os.IsNotExist(err) { - if err := os.MkdirAll(filepath.Dir(file), 0700); err != nil { - return nil, err - } - } - return &DB{Debug: debug, Dbfile: file}, nil } func (db *DB) Open() error { + if _, err := os.Stat(filepath.Dir(db.Dbfile)); os.IsNotExist(err) { + if err := os.MkdirAll(filepath.Dir(db.Dbfile), 0700); err != nil { + return err + } + } + b, err := bolt.Open(db.Dbfile, 0600, nil) if err != nil { return fmt.Errorf("failed to open DB %s: %w", db.Dbfile, err) diff --git a/cmd/anydb.go b/cmd/anydb.go index 13a1e8b..23dc49a 100644 --- a/cmd/anydb.go +++ b/cmd/anydb.go @@ -42,28 +42,3 @@ AUTHORS Thomas von Dein tom AT vondein DOT org ` -var usage = ` - -Usage: - anydb [options] [flags] - anydb [command] - -Available Commands: - completion Generate the autocompletion script for the specified shell - del Delete key - export Export database to json - get Retrieve value for a key - help Help about any command - import Import database dump - list List database contents - set Insert key/value pair - -Flags: - -f, --dbfile string DB file to use (default "/home/scip/.config/anydb/default.db") - -d, --debug Enable debugging - -h, --help help for anydb - -v, --version Print program version - -Use "anydb [command] --help" for more information about a command. - -`