mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
- `internal/terminal`: streams and the prompting policy, interactive forms (issue, PR, review, merge, milestone), editor / pager / browser launching, JSON and `--jq` output. - An aligned table renderer and a record renderer for human output; both strip control and escape characters from server-supplied text so titles and bodies cannot inject terminal sequences. Reviewed-on: https://gitea.com/gitea/tea/pulls/1124 Reviewed-by: TheFox0x7 <95654+thefox0x7@noreply.gitea.com>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package terminal
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"time"
|
|
|
|
"charm.land/huh/v2"
|
|
)
|
|
|
|
// MilestoneFormValues holds interactively collected milestone create fields.
|
|
type MilestoneFormValues struct {
|
|
Title, Description string
|
|
Deadline *time.Time
|
|
}
|
|
|
|
// MilestoneForm collects interactive milestone create input.
|
|
type MilestoneForm interface {
|
|
CreateMilestone(context.Context) (MilestoneFormValues, error)
|
|
}
|
|
|
|
// CreateMilestone runs the interactive milestone create form on stderr.
|
|
func (p *FormPrompter) CreateMilestone(ctx context.Context) (MilestoneFormValues, error) {
|
|
title, description, deadline := "", "", ""
|
|
if err := p.runForm(ctx, huh.NewForm(huh.NewGroup(
|
|
huh.NewInput().Title("Milestone title (required):").Value(&title).Validate(huh.ValidateNotEmpty()),
|
|
huh.NewText().Title("Milestone description (markdown):").Value(&description),
|
|
dueDateInput("Milestone deadline:", &deadline),
|
|
))); err != nil {
|
|
return MilestoneFormValues{}, err
|
|
}
|
|
parsed, err := parseDueDate(deadline)
|
|
return MilestoneFormValues{Title: strings.TrimSpace(title), Description: description, Deadline: parsed}, err
|
|
}
|