Merge branch 'main' of github.com:TLINDEN/anydb

This commit is contained in:
2024-12-19 10:57:56 +01:00
3 changed files with 7 additions and 32 deletions

View File

@@ -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: .\" Standard preamble:
.\" ======================================================================== .\" ========================================================================

View File

@@ -38,16 +38,16 @@ type DbTag struct {
const BucketData string = "data" const BucketData string = "data"
func New(file string, debug bool) (*DB, error) { 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 return &DB{Debug: debug, Dbfile: file}, nil
} }
func (db *DB) Open() error { 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) b, err := bolt.Open(db.Dbfile, 0600, nil)
if err != nil { if err != nil {
return fmt.Errorf("failed to open DB %s: %w", db.Dbfile, err) return fmt.Errorf("failed to open DB %s: %w", db.Dbfile, err)

View File

@@ -42,28 +42,3 @@ AUTHORS
Thomas von Dein tom AT vondein DOT org Thomas von Dein tom AT vondein DOT org
` `
var usage = `
Usage:
anydb <command> [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.
`