2021-01-31 03:14:33 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2021-02-18 08:50:47 +00:00
|
|
|
"strings"
|
2021-01-31 03:14:33 +00:00
|
|
|
|
2021-02-06 09:13:55 +00:00
|
|
|
"github.com/jedib0t/go-pretty/v6/table"
|
|
|
|
|
2021-01-31 03:14:33 +00:00
|
|
|
"gitlab.com/signald/signald-go/signald"
|
2021-02-18 08:50:47 +00:00
|
|
|
"gitlab.com/signald/signald-go/signald/client-protocol/v1"
|
2021-01-31 03:14:33 +00:00
|
|
|
)
|
|
|
|
|
2021-02-02 21:50:44 +00:00
|
|
|
const (
|
2021-02-03 01:13:31 +00:00
|
|
|
OutputFormatDefault = "default"
|
|
|
|
OutputFormatCSV = "csv"
|
|
|
|
OutputFormatTable = "table"
|
|
|
|
OutputFormatJSON = "json"
|
|
|
|
OutputFormatYAML = "yaml"
|
|
|
|
OutputFormatQR = "qr"
|
|
|
|
OutputFormatMarkdown = "md"
|
|
|
|
OutputFormatMan = "man"
|
2021-02-02 21:50:44 +00:00
|
|
|
|
|
|
|
AnnotationNoSocketConnection = "no-socket"
|
|
|
|
)
|
|
|
|
|
2021-01-31 03:14:33 +00:00
|
|
|
var (
|
|
|
|
Signald *signald.Signald
|
|
|
|
|
|
|
|
OutputFormat string
|
|
|
|
)
|
|
|
|
|
|
|
|
func Must(err error) {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2021-02-06 09:13:55 +00:00
|
|
|
|
|
|
|
func StylizeTable(t table.Writer) {
|
|
|
|
t.SetStyle(table.StyleLight)
|
|
|
|
}
|
2021-02-18 08:50:47 +00:00
|
|
|
|
|
|
|
func StringToAddress(address string) v1.JsonAddress {
|
|
|
|
if strings.HasPrefix(address, "+") {
|
|
|
|
return v1.JsonAddress{Number: address}
|
|
|
|
}
|
|
|
|
return v1.JsonAddress{UUID: address}
|
|
|
|
}
|