diff --git a/cmd/signaldctl/cmd/doc.go b/cmd/signaldctl/cmd/doc.go index 33cc103..33b00af 100644 --- a/cmd/signaldctl/cmd/doc.go +++ b/cmd/signaldctl/cmd/doc.go @@ -25,12 +25,14 @@ import ( "github.com/spf13/cobra" "github.com/spf13/cobra/doc" + "gitlab.com/signald/signald-go/cmd/signaldctl/common" ) var DocCmd = &cobra.Command{ - Use: "doc", - Aliases: []string{"docs"}, - Hidden: true, + Use: "doc", + Aliases: []string{"docs"}, + Hidden: true, + Annotations: map[string]string{common.AnnotationNoSocketConnection: "true"}, Run: func(_ *cobra.Command, _ []string) { err := doc.GenMarkdownTreeCustom(RootCmd, "./docs/content/signaldctl", filePrepender, linkHandler) if err != nil { diff --git a/cmd/signaldctl/cmd/root.go b/cmd/signaldctl/cmd/root.go index 81b45b6..54c916d 100644 --- a/cmd/signaldctl/cmd/root.go +++ b/cmd/signaldctl/cmd/root.go @@ -43,6 +43,11 @@ var RootCmd = &cobra.Command{ if socketPath == "" { socketPath = config.Config.SocketPath } + + if _, ok := cmd.Annotations[common.AnnotationNoSocketConnection]; ok { + return + } + common.Signald = &signald.Signald{SocketPath: config.Config.SocketPath} if err := common.Signald.Connect(); err != nil { log.Fatal(err) diff --git a/cmd/signaldctl/common/output-formats.go b/cmd/signaldctl/common/output-formats.go deleted file mode 100644 index 61440ec..0000000 --- a/cmd/signaldctl/common/output-formats.go +++ /dev/null @@ -1,10 +0,0 @@ -package common - -const ( - OutputFormatDefault = "default" - OutputFormatCSV = "csv" - OutputFormatTable = "table" - OutputFormatJSON = "json" - OutputFormatYAML = "yaml" - OutputFormatQR = "qr" -) diff --git a/cmd/signaldctl/common/signald.go b/cmd/signaldctl/common/signald.go index 3287838..2e9569f 100644 --- a/cmd/signaldctl/common/signald.go +++ b/cmd/signaldctl/common/signald.go @@ -6,6 +6,17 @@ import ( "gitlab.com/signald/signald-go/signald" ) +const ( + OutputFormatDefault = "default" + OutputFormatCSV = "csv" + OutputFormatTable = "table" + OutputFormatJSON = "json" + OutputFormatYAML = "yaml" + OutputFormatQR = "qr" + + AnnotationNoSocketConnection = "no-socket" +) + var ( Signald *signald.Signald