48 lines
810 B
Go
48 lines
810 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"git.luj0ga.de/franconian/matrix-pretix/internal/matrix"
|
||
|
"git.luj0ga.de/franconian/matrix-pretix/internal/util"
|
||
|
)
|
||
|
|
||
|
func login() {
|
||
|
prompter := util.NewPrompter(bufio.NewScanner(os.Stdin))
|
||
|
|
||
|
identifier, err := prompter.Prompt("user id")
|
||
|
if err != nil {
|
||
|
fmt.Fprintln(os.Stderr, err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
|
||
|
password, err := util.PromptForPassword("password")
|
||
|
if err != nil {
|
||
|
fmt.Fprintln(os.Stderr, err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
|
||
|
err = matrix.Login(identifier, password)
|
||
|
if err != nil {
|
||
|
fmt.Fprintln(os.Stderr, err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func run() {
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
switch {
|
||
|
case len(os.Args) == 2 && os.Args[1] == "login":
|
||
|
login()
|
||
|
case len(os.Args) == 1:
|
||
|
run()
|
||
|
default:
|
||
|
fmt.Fprintf(os.Stderr, "usage: %s [ \"\" | \"login\" ]\n", os.Args[0])
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
}
|