summaryrefslogtreecommitdiff
path: root/conf/endpoint.go
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-10 14:15:30 -0500
committersanine-a <sanine.not@pm.me>2023-05-10 14:15:30 -0500
commitc4dbe6328640f8ac43518a642e77dec061bfdd03 (patch)
treed432f0c0522d946e9b42f39c8960a3b37f4af37d /conf/endpoint.go
parentfd994ce631ce7244157f81678574e6bc420d0fcc (diff)
add hacky command parser
Diffstat (limited to 'conf/endpoint.go')
-rw-r--r--conf/endpoint.go98
1 files changed, 0 insertions, 98 deletions
diff --git a/conf/endpoint.go b/conf/endpoint.go
deleted file mode 100644
index 1f8fa11..0000000
--- a/conf/endpoint.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package main
-
-import (
- "fmt"
- "log"
- db "sanine.net/git/phlox/db"
-)
-
-
-func CreateEndpoint() *Command {
- return &Command{
- Flag: "create-endpoint",
- Usage: "create a new endpoint",
- Invoke: func() {
- OpenDb()
-
- name := ReadLine("Endpoint Name: ")
- path := ReadLine("Endpoint Path: ")
- address := ReadLine("Endpoint Address: ")
- _, err := p.CreateEndpoint(name, path, address)
- if err != nil { log.Fatal(err) }
- fmt.Printf("created endpoint %v\n", name)
- },
- }
-}
-
-
-func GetEndpoint() db.Endpoint {
- OpenDb()
- name := ReadLine("Endpoint Name: ")
- endpoint, err := p.GetEndpointByName(name)
- if err != nil { log.Fatal(err) }
- return endpoint
-}
-
-
-func DeleteEndpoint() *Command {
- return &Command{
- Flag: "delete-endpoint",
- Usage: "delete an existing endpoint",
- Invoke: func() {
- endpoint := GetEndpoint()
- err := p.DeleteEndpoint(endpoint)
- if err != nil { log.Fatal(err) }
- fmt.Printf("deleted endpoint %v\n", endpoint.Name)
- },
- }
-}
-
-
-func SetPath() *Command {
- return &Command{
- Flag: "set-endpoint-path",
- Usage: "set the path of an existing endpoint",
- Invoke: func() {
- endpoint := GetEndpoint()
- fmt.Printf("Current Path: %v\n", endpoint.Path)
- path := ReadLine("New Path: ")
- err := p.SetEndpointPath(endpoint, path)
- if err != nil { log.Fatal(err) }
- fmt.Printf("updated path for endpoint %v\n", endpoint.Name)
- },
- }
-}
-
-
-func SetAddress() *Command {
- return &Command{
- Flag: "set-endpoint-address",
- Usage: "set the address of an existing endpoint",
- Invoke: func() {
- endpoint := GetEndpoint()
- fmt.Printf("Current Address: %v\n", endpoint.Address)
- address := ReadLine("New Address: ")
- err := p.SetEndpointAddress(endpoint, address)
- if err != nil { log.Fatal(err) }
- fmt.Printf("updated address for endpoint %v\n", endpoint.Name)
- },
- }
-}
-
-
-func ListEndpoints() *Command {
- return &Command{
- Flag: "list-endpoints",
- Usage: "list all endpoints",
- Invoke: func() {
- OpenDb()
- endpoints, err := p.AllEndpoints()
- if err != nil { log.Fatal(err) }
- fmt.Println("id\t\tname\t\tpath\t\taddress")
- fmt.Println("================================================================================")
- for _, endpoint := range endpoints {
- fmt.Printf("%v\t\t%v\t\t%v\t\t%v\n", endpoint.Id, endpoint.Name, endpoint.Path, endpoint.Address)
- }
- },
- }
-}