diff --git a/action/generate.go b/action/generate.go index 8e566ff92e..60af88aa4c 100644 --- a/action/generate.go +++ b/action/generate.go @@ -70,5 +70,9 @@ func (s *Action) Generate(c *cli.Context) error { color.YellowString(string(password)), ) + if s.Store.AskForMore() && askForConfirmation(fmt.Sprintf("Do you want to add more data for %s?", name)) { + return s.Edit(c) + } + return nil } diff --git a/config/config.go b/config/config.go index d6f3c4a144..a03c47ed2c 100644 --- a/config/config.go +++ b/config/config.go @@ -17,6 +17,7 @@ import ( // Config is the gopass config structure type Config struct { AlwaysTrust bool `json:"alwaystrust"` // always trust public keys when encrypting + AskForMore bool `json:"askformore"` // ask for more data on generate AutoImport bool `json:"autoimport"` // import missing public keys w/o asking AutoPull bool `json:"autopull"` // pull from git before push AutoPush bool `json:"autopush"` // push to git remote after commit @@ -38,6 +39,7 @@ type Config struct { func New() *Config { return &Config{ AlwaysTrust: true, + AskForMore: false, AutoImport: true, AutoPull: true, AutoPush: true, diff --git a/store/root/config.go b/store/root/config.go index de9a49e33d..d39a407712 100644 --- a/store/root/config.go +++ b/store/root/config.go @@ -10,6 +10,7 @@ import ( func (s *Store) Config() *config.Config { c := &config.Config{ AlwaysTrust: s.alwaysTrust, + AskForMore: s.askForMore, AutoImport: s.autoImport, AutoPull: s.autoPull, AutoPush: s.autoPush, @@ -36,6 +37,7 @@ func (s *Store) UpdateConfig(cfg *config.Config) error { return fmt.Errorf("invalid config") } s.alwaysTrust = cfg.AlwaysTrust + s.askForMore = cfg.AskForMore s.autoImport = cfg.AutoImport s.autoPull = cfg.AutoPull s.autoPush = cfg.AutoPush @@ -108,3 +110,8 @@ func (s *Store) SafeContent() bool { func (s *Store) ClipTimeout() int { return s.clipTimeout } + +// AskForMore returns true if generate should ask for more information +func (s *Store) AskForMore() bool { + return s.askForMore +} diff --git a/store/root/store.go b/store/root/store.go index c80e0e2c4f..a50921d7b0 100644 --- a/store/root/store.go +++ b/store/root/store.go @@ -17,6 +17,7 @@ import ( // Store is the public facing password store type Store struct { alwaysTrust bool // always trust public keys when encrypting + askForMore bool autoImport bool // import missing public keys w/o asking autoPull bool // pull from git before push autoPush bool // push to git remote after commit @@ -45,6 +46,7 @@ func New(cfg *config.Config) (*Store, error) { } r := &Store{ alwaysTrust: cfg.AlwaysTrust, + askForMore: cfg.AskForMore, autoImport: cfg.AutoImport, autoPull: cfg.AutoPull, autoPush: cfg.AutoPush,