WIP start writing this for real

pull/1/head
vilmibm 2023-02-03 05:03:03 +00:00
parent cf99807126
commit 6b86087c0e
1 changed files with 55 additions and 23 deletions

View File

@ -30,15 +30,13 @@ in sshd_config, and:
auth [success=done default=ignore] pam_succeed_if.so user ingroup join auth [success=done default=ignore] pam_succeed_if.so user ingroup join
in /etc/pam.d/sshd in /etc/pam.d/sshd
*/ */
/* type TownApplication struct {
Email string
is there a way :qa // TODO
}
*/
type streams struct { type streams struct {
In io.Reader In io.Reader
@ -46,6 +44,55 @@ type streams struct {
Err io.Writer Err io.Writer
} }
func cli(s *streams) error {
pages := tview.NewPages()
mainFlex := tview.NewFlex()
innerFlex := tview.NewFlex()
input := tview.NewTextArea()
title := tview.NewTextView()
title.SetDynamicColors(true)
title.SetTextAlign(tview.AlignCenter)
title.SetText("[purple]the tilde town sign up portal[-]")
msgScroll := tview.NewTextView()
msgScroll.SetDynamicColors(true)
sidebar := tview.NewTextView()
sidebar.SetBorder(true)
sidebar.SetDynamicColors(true)
sidebar.SetText("[-:-:b]pbbt[-:-:-]")
innerFlex.SetDirection(tview.FlexColumn)
innerFlex.AddItem(msgScroll, 0, 2, false)
innerFlex.AddItem(sidebar, 0, 1, false)
mainFlex.SetDirection(tview.FlexRow)
mainFlex.AddItem(title, 1, -1, false)
mainFlex.AddItem(innerFlex, 0, 1, false)
mainFlex.AddItem(input, 5, -1, true)
pages.AddPage("main", mainFlex, true, true)
app := tview.NewApplication()
app.SetRoot(pages, true)
return app.Run()
}
func main() {
s := &streams{
In: os.Stdin,
Out: os.Stdout,
Err: os.Stderr,
}
err := cli(s)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
type Prompter struct { type Prompter struct {
in io.Reader in io.Reader
out io.Writer out io.Writer
@ -203,8 +250,8 @@ func _main(args []string, s *streams) error {
exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run() exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run()
// LOL i don't think this will work // LOL i don't think this will work
reader := bufio.NewReader(p.in) //reader := bufio.NewReader(p.in)
s, _ := reader.ReadString(4) //s, _ := reader.ReadString(4)
fmt.Printf("DBG %#v\n", s) fmt.Printf("DBG %#v\n", s)
//var b []byte = make([]byte, 100) //var b []byte = make([]byte, 100)
//for { //for {
@ -349,18 +396,3 @@ func edit(s *streams, a *answers) error {
return app.SetRoot(form, true).EnableMouse(true).Run() return app.SetRoot(form, true).EnableMouse(true).Run()
} }
func main() {
retcode := 0
s := &streams{
In: os.Stdin,
Out: os.Stdout,
Err: os.Stderr,
}
err := _main(os.Args, s)
if err != nil {
retcode = 1
fmt.Fprintln(os.Stderr, err)
}
os.Exit(retcode)
}