Home

ugit @8445f0c8981c322218057d60e8662150ee3569a5 - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
ugit / internal / ssh / form.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ssh

import (
	"strings"

	"github.com/charmbracelet/huh"
	"go.jolheiser.com/ugit/internal/git"
)

type stringSliceAccessor []string

func (s stringSliceAccessor) Get() string {
	return strings.Join(s, "\n")
}

func (s stringSliceAccessor) Set(value string) {
	s = strings.Split(value, "\n")
}

func newForm(meta git.RepoMeta) *huh.Form {
	return huh.NewForm(
		huh.NewGroup(
			huh.NewText().
				Title("Description").
				Value(&meta.Description),
			huh.NewConfirm().
				Title("Visibility").
				Affirmative("Public").
				Negative("Private").
				Value(&meta.Private),
			huh.NewText().
				Title("Tags").
				Description("One per line").
				Accessor(stringSliceAccessor(meta.Tags)),
		),
	)
}