Skip to content

Commit

Permalink
Ask for additional information on generate (gopasspw#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Jun 16, 2017
1 parent 909ac08 commit 96b386a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions action/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,6 +39,7 @@ type Config struct {
func New() *Config {
return &Config{
AlwaysTrust: true,
AskForMore: false,
AutoImport: true,
AutoPull: true,
AutoPush: true,
Expand Down
7 changes: 7 additions & 0 deletions store/root/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions store/root/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 96b386a

Please sign in to comment.