summaryrefslogtreecommitdiff
path: root/conf/create.go
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-05-13 22:32:24 -0500
committersanine <sanine.not@pm.me>2023-05-13 22:32:24 -0500
commit9571ccc4d87907067df98edeaa78f0c167fcff43 (patch)
treee64760fa34d7ecfd8460596b8ddf314ceacda2b7 /conf/create.go
parent609ef3f3b4d4cb355d80b19df1e91db258b0bbe0 (diff)
begin total refactor
Diffstat (limited to 'conf/create.go')
-rw-r--r--conf/create.go83
1 files changed, 0 insertions, 83 deletions
diff --git a/conf/create.go b/conf/create.go
deleted file mode 100644
index 201149a..0000000
--- a/conf/create.go
+++ /dev/null
@@ -1,83 +0,0 @@
-package main
-
-
-import (
- "fmt"
- "log"
- "strings"
- "syscall"
- "golang.org/x/term"
-)
-
-
-func hiddenPrompt(prompt string) (string, error) {
- fmt.Print(prompt)
- bytes, err := term.ReadPassword(int(syscall.Stdin))
- if err != nil {
- return "", err
- }
- fmt.Println()
-
- return strings.TrimSpace(string(bytes)), nil
-}
-
-
-var createUser = &Command{
- Name: "user",
- Execute: func(args []string) {
- if len(args) < 1 {
- fmt.Println("error: no username provided")
- return;
- }
- username := args[0]
- var password string
- var err error
- if len(args) == 1 {
- password, err = hiddenPrompt("Enter password: ")
- if err != nil { log.Fatal(err) }
- confirm, err := hiddenPrompt("Confirm password: ")
- if err != nil { log.Fatal(err) }
- if password != confirm {
- fmt.Println("passwords do not match!")
- return
- }
- } else {
- password = args[1]
- }
-
- _, err = p.CreateUser(username, password)
- if err != nil { log.Fatal(err) }
- fmt.Printf("created user %v\n", username)
- },
-}
-
-
-var createEndpoint = &Command{
- Name: "endpoint",
- Execute: func(args []string) {
- if len(args) < 3 {
- fmt.Println("error: name, URI, and address must be specified!")
- return
- }
-
- name := args[0]
- path := args[1]
- addr := args[2]
-
- _, err := p.CreateEndpoint(name, path, addr)
- if err != nil { log.Fatal(err) }
- fmt.Printf("created endpoint %v\n", name)
- },
-}
-
-
-func CreateInit(parser *Command) {
- create := &Command{
- Name: "create",
- Branch: true,
- }
-
- create.AddCommand(createUser)
- create.AddCommand(createEndpoint)
- parser.AddCommand(create)
-}