Skip to content
Permalink
Browse files

Optional backup flag

  • Loading branch information...
Raggaer committed Feb 22, 2019
1 parent df52381 commit 9fd1d44dd5204ec743c3063bfaf4da72cda9250f
Showing with 8 additions and 4 deletions.
  1. +2 −0 main.go
  2. +6 −4 save.go
@@ -20,12 +20,14 @@ var (
databaseLocation string
passwordFileLocation string
database *gokeepasslib.Database
doNotBackups = false
)

func main() {
// Parse application flags
flag.StringVar(&databaseLocation, "db", "", "KeePass2 database file location")
flag.StringVar(&passwordFileLocation, "pwfile", "", "File that stores your KeePass2 database password")
flag.BoolVar(&doNotBackups, "nbackup", false, "Do not use the builtin backup method")
flag.Parse()

// Open database file
10 save.go
@@ -20,10 +20,12 @@ func databaseChangedSaveAlert(f *form, answer string) {
activeForm = nil
}()
// First we backup the database
if err := backupDatabase(); err != nil {
fmt.Println("Unable to backup database:")
fmt.Println(err.Error())
return
if doNotBackups {
if err := backupDatabase(); err != nil {
fmt.Println("Unable to backup database:")
fmt.Println(err.Error())
return
}
}
if strings.TrimSpace(answer) != "y" {
return

0 comments on commit 9fd1d44

Please sign in to comment.
You can’t perform that action at this time.