signald-go/cmd/signaldctl/common/signald.go

49 lines
889 B
Go
Raw Normal View History

2021-01-31 03:14:33 +00:00
package common
import (
"log"
"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"
"gitlab.com/signald/signald-go/signald/client-protocol/v1"
2021-01-31 03:14:33 +00:00
)
const (
OutputFormatDefault = "default"
OutputFormatCSV = "csv"
OutputFormatTable = "table"
OutputFormatJSON = "json"
OutputFormatYAML = "yaml"
OutputFormatQR = "qr"
OutputFormatMarkdown = "md"
OutputFormatMan = "man"
2021-07-23 23:54:53 +00:00
OutputFormatQuiet = "quiet"
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)
}
func StringToAddress(address string) v1.JsonAddress {
if strings.HasPrefix(address, "+") {
return v1.JsonAddress{Number: address}
}
return v1.JsonAddress{UUID: address}
}