mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
Feat: interactive issue edit command (#708)
If there are no flags passed to the `issues edit` command, it prompts for changes to the properties like title, description, labels, etc. This is a follow-up to <https://gitea.com/gitea/tea/pulls/506>. Closes: <https://gitea.com/gitea/tea/issues/605> Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/708 Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com> Co-authored-by: Vincent Neubauer <v.neubauer@darlor.de> Co-committed-by: Vincent Neubauer <v.neubauer@darlor.de>
This commit is contained in:

committed by
techknowlogick

parent
60636cd7d8
commit
57e3400f0f
@ -15,10 +15,12 @@ import (
|
||||
|
||||
// Multiline represents options for a prompt that expects multiline input
|
||||
type Multiline struct {
|
||||
Message string
|
||||
Default string
|
||||
Syntax string
|
||||
UseEditor bool
|
||||
Message string
|
||||
Default string
|
||||
Syntax string
|
||||
UseEditor bool
|
||||
EditorAppendDefault bool
|
||||
EditorHideDefault bool
|
||||
}
|
||||
|
||||
// NewMultiline creates a prompt that switches between the inline multiline text
|
||||
@ -26,9 +28,11 @@ type Multiline struct {
|
||||
func NewMultiline(opts Multiline) (prompt survey.Prompt) {
|
||||
if opts.UseEditor {
|
||||
prompt = &survey.Editor{
|
||||
Message: opts.Message,
|
||||
Default: opts.Default,
|
||||
FileName: "*." + opts.Syntax,
|
||||
Message: opts.Message,
|
||||
Default: opts.Default,
|
||||
FileName: "*." + opts.Syntax,
|
||||
AppendDefault: opts.EditorAppendDefault,
|
||||
HideDefault: opts.EditorHideDefault,
|
||||
}
|
||||
} else {
|
||||
prompt = &survey.Multiline{Message: opts.Message, Default: opts.Default}
|
||||
@ -146,13 +150,17 @@ func promptSelectV2(prompt string, options []string) (string, error) {
|
||||
}
|
||||
|
||||
// promptSelect creates a generic select prompt, with processing of custom values or none-option.
|
||||
func promptSelect(prompt string, options []string, customVal, noneVal string) (string, error) {
|
||||
func promptSelect(prompt string, options []string, customVal, noneVal, defaultVal string) (string, error) {
|
||||
var selection string
|
||||
if defaultVal == "" && noneVal != "" {
|
||||
defaultVal = noneVal
|
||||
|
||||
}
|
||||
promptA := &survey.Select{
|
||||
Message: prompt,
|
||||
Options: makeSelectOpts(options, customVal, noneVal),
|
||||
VimMode: true,
|
||||
Default: noneVal,
|
||||
Default: defaultVal,
|
||||
}
|
||||
if err := survey.AskOne(promptA, &selection); err != nil {
|
||||
return "", err
|
||||
|
Reference in New Issue
Block a user