feat: prompt select for scope if scope.values is defined
This commit is contained in:
parent
3aa2ecc487
commit
d88d185b2b
2 changed files with 9 additions and 2 deletions
|
@ -270,7 +270,7 @@ func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor)
|
|||
return err
|
||||
}
|
||||
|
||||
scope, err := promptScope()
|
||||
scope, err := promptScope(cfg.CommitMessage.Scope.Values)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -46,7 +46,14 @@ func promptType() (commitType, error) {
|
|||
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-]*$", "")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue