This commit is contained in:
parent
c23802216e
commit
c10bf83c41
|
@ -19,6 +19,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
|
@ -29,6 +30,10 @@ import (
|
|||
"p83.nl/go/ekster/pkg/microsub"
|
||||
)
|
||||
|
||||
var (
|
||||
verbose = flag.Bool("verbose", false, "show verbose logging")
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetFlags(log.Lshortfile | log.Ldate | log.Ltime)
|
||||
}
|
||||
|
@ -102,6 +107,8 @@ func loadEndpoints(c *client.Client, me *url.URL, filename string) error {
|
|||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
configDir := fmt.Sprintf("%s/.config/microsub", os.Getenv("HOME"))
|
||||
|
||||
if len(os.Args) == 3 && os.Args[1] == "connect" {
|
||||
|
@ -156,7 +163,9 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
performCommands(&c, os.Args[1:])
|
||||
c.Logging = *verbose
|
||||
|
||||
performCommands(&c, flag.Args())
|
||||
}
|
||||
|
||||
func performCommands(sub microsub.Microsub, commands []string) {
|
||||
|
|
|
@ -17,7 +17,7 @@ type Client struct {
|
|||
MicrosubEndpoint *url.URL
|
||||
Token string
|
||||
|
||||
logging bool
|
||||
Logging bool
|
||||
}
|
||||
|
||||
func (c *Client) microsubGetRequest(action string, args map[string]string) (*http.Response, error) {
|
||||
|
@ -38,14 +38,14 @@ func (c *Client) microsubGetRequest(action string, args map[string]string) (*htt
|
|||
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.Token))
|
||||
|
||||
if c.logging {
|
||||
if c.Logging {
|
||||
x, _ := httputil.DumpRequestOut(req, true)
|
||||
log.Printf("REQUEST:\n\n%s\n\n", x)
|
||||
}
|
||||
|
||||
res, err := client.Do(req)
|
||||
|
||||
if c.logging {
|
||||
if c.Logging {
|
||||
x, _ := httputil.DumpResponse(res, true)
|
||||
log.Printf("RESPONSE:\n\n%s\n\n", x)
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ func (c *Client) microsubPostRequest(action string, args map[string]string) (*ht
|
|||
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.Token))
|
||||
|
||||
if c.logging {
|
||||
if c.Logging {
|
||||
x, _ := httputil.DumpRequestOut(req, true)
|
||||
log.Printf("REQUEST:\n\n%s\n\n", x)
|
||||
}
|
||||
|
||||
res, err := client.Do(req)
|
||||
|
||||
if c.logging {
|
||||
if c.Logging {
|
||||
x, _ := httputil.DumpResponse(res, true)
|
||||
log.Printf("RESPONSE:\n\n%s\n\n", x)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user