func addSecret(ps *store.SecretStore, cfg *config, m secret.ScryptMode) error { if cfg.WithMeta { return addMeta(ps, cfg, m) } label := cfg.Args[0] var rec *store.SecretRecord if ps.Has(label) { if !cfg.Overwrite { return errors.New("entry exists, not forcing overwrite") } util.Errorf("*** WARNING: overwriting password") rec = ps.Store[label] } else { rec = &store.SecretRecord{Label: label} } password, err := readpass.PasswordPromptBytes("New password: "******"no password entered") } rec.Secret = password rec.Timestamp = time.Now().Unix() ps.Store[label] = rec return nil }
func multi(ps *store.SecretStore, cfg *config, m secret.ScryptMode) error { fmt.Println("Use an empty name to indicate that you are done.") for { name, err := util.ReadLine("Name: ") if err != nil { return err } else if name == "" { break } var rec *store.SecretRecord if ps.Has(name) { if !cfg.Overwrite { util.Errorf("Entry exists, not forcing overwrite.") continue } else { util.Errorf("*** WARNING: overwriting password") } rec = ps.Store[name] } else { rec = &store.SecretRecord{ Label: name, } } password, err := util.PassPrompt("Password: "******"No password entered.") continue } rec.Secret = password rec.Timestamp = time.Now().Unix() ps.Store[name] = rec } return nil }