MCPcopy Create free account
hub / github.com/Xpl0itU/passiveMachine / ConfigureForm

Method ConfigureForm

grass.go:22–62  ·  view source on GitHub ↗
(form *tview.Form, frame *tview.Frame, app *tview.Application)

Source from the content-addressed store, hash-verified

20}
21
22func (i *GrassConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
23 email := ""
24 password := ""
25 isError := false
26 showingError := false
27 form.AddInputField("Email", i.Email, 50, nil, func(text string) {
28 email = text
29 })
30 form.AddPasswordField("Password", i.Password, 20, '*', func(text string) {
31 password = text
32 })
33 form.AddButton("Save", func() {
34 isError = stringIsEmpty(email) || stringIsEmpty(password)
35 if isError {
36 if !showingError {
37 form.AddTextView("Error", "All fields are required", 0, 1, true, true)
38 showingError = true
39 }
40 return
41 }
42 i.Email = email
43 i.Password = password
44 i.Configured = true
45 returnToMenu(frame, app)
46 })
47 form.AddButton("Cancel", func() {
48 returnToMenu(frame, app)
49 })
50 form.AddButton("Register", func() {
51 modal := tview.NewModal().
52 SetText("Register on Grass\n" + GRASS_REFERRAL_LINK).
53 AddButtons([]string{"Open", "Cancel"}).
54 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
55 if buttonLabel == "Open" {
56 webbrowser.Open(GRASS_REFERRAL_LINK)
57 }
58 app.SetRoot(form, true)
59 })
60 app.SetRoot(modal, true)
61 })
62}
63
64func (i *GrassConfig) ConfigureDocker(kind DockerConfigKind, form *tview.Form) (string, error) {
65 switch kind {

Callers

nothing calls this directly

Calls 2

stringIsEmptyFunction · 0.85
returnToMenuFunction · 0.85

Tested by

no test coverage detected