More plumbing

This commit is contained in:
Adam Ierymenko 2019-10-02 07:09:54 -07:00
commit b9911d0db7
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
18 changed files with 384 additions and 114 deletions

View file

@ -13,6 +13,27 @@
package cli
import (
"fmt"
"net/http"
"net/url"
"os"
"strings"
"zerotier/pkg/zerotier"
)
// RemoveRoot CLI command
func RemoveRoot(basePath, authToken string, args []string) {
if len(args) != 1 {
Help()
os.Exit(1)
}
result, _ := zerotier.APIDelete(basePath, zerotier.APISocketName, authToken, "/root/"+url.PathEscape(strings.TrimSpace(args[0])), nil)
if result == http.StatusOK {
fmt.Printf("%s removed\n", args[0])
os.Exit(0)
}
fmt.Printf("ERROR: root %s not found or another error occurred: status code %d\n", args[0], result)
os.Exit(1)
}