0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-25 07:30:38 +00:00

feat: prompt select for scope if scope.values is defined

This commit is contained in:
Beatriz Vieira 2021-02-14 20:12:36 -03:00
parent 3aa2ecc487
commit d88d185b2b
2 changed files with 9 additions and 2 deletions

View File

@ -270,7 +270,7 @@ func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor)
return err return err
} }
scope, err := promptScope() scope, err := promptScope(cfg.CommitMessage.Scope.Values)
if err != nil { if err != nil {
return err return err
} }

View File

@ -46,7 +46,14 @@ func promptType() (commitType, error) {
return items[i], nil return items[i], nil
} }
func promptScope() (string, error) { func promptScope(values []string) (string, error) {
if len(values) > 0 {
selected, err := promptSelect("scope", values, nil)
if err != nil {
return "", err
}
return values[selected], nil
}
return promptText("scope", "^[a-z0-9-]*$", "") return promptText("scope", "^[a-z0-9-]*$", "")
} }