Skip to content

Commit

Permalink
Merge branch 'main' of github.com:TLINDEN/anydb
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas von Dein committed Dec 19, 2024
2 parents 9783707 + d1e813f commit daf52ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
2 changes: 1 addition & 1 deletion anydb.1
Original file line number Diff line number Diff line change
@@ -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:
.\" ========================================================================
Expand Down
12 changes: 6 additions & 6 deletions app/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 0 additions & 25 deletions cmd/anydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,3 @@ AUTHORS
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.
`

0 comments on commit daf52ba

Please sign in to comment.