aboutsummaryrefslogtreecommitdiffstats
path: root/client/go
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-09-07 14:42:42 +0200
committerMartin Polden <mpolden@mpolden.no>2021-09-07 15:02:15 +0200
commita364de5217b3ff3028dd833ba99374e893bc037f (patch)
tree47fcd1cc2285cebccd4ba87ae6952e6022738b5f /client/go
parent4793f8e7e063bc22047ad9851df3dd8cfea4a3fe (diff)
Add command for generating man pages
Diffstat (limited to 'client/go')
-rw-r--r--client/go/cmd/api_key.go9
-rw-r--r--client/go/cmd/cert.go9
-rw-r--r--client/go/cmd/clone.go3
-rw-r--r--client/go/cmd/config.go23
-rw-r--r--client/go/cmd/deploy.go19
-rw-r--r--client/go/cmd/document.go15
-rw-r--r--client/go/cmd/man.go27
-rw-r--r--client/go/cmd/man_test.go17
-rw-r--r--client/go/cmd/query.go3
-rw-r--r--client/go/cmd/root.go2
-rw-r--r--client/go/cmd/status.go36
-rw-r--r--client/go/cmd/version.go7
-rw-r--r--client/go/go.sum3
13 files changed, 121 insertions, 52 deletions
diff --git a/client/go/cmd/api_key.go b/client/go/cmd/api_key.go
index c3a111b0f15..b465a3b8add 100644
--- a/client/go/cmd/api_key.go
+++ b/client/go/cmd/api_key.go
@@ -23,10 +23,11 @@ func init() {
}
var apiKeyCmd = &cobra.Command{
- Use: "api-key",
- Short: "Create a new user API key for authentication with Vespa Cloud",
- Example: "$ vespa api-key -a my-tenant.my-app.my-instance",
- Args: cobra.ExactArgs(0),
+ Use: "api-key",
+ Short: "Create a new user API key for authentication with Vespa Cloud",
+ Example: "$ vespa api-key -a my-tenant.my-app.my-instance",
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
configDir := configDir("")
if configDir == "" {
diff --git a/client/go/cmd/cert.go b/client/go/cmd/cert.go
index 0cf220783d5..e1e11b6f73e 100644
--- a/client/go/cmd/cert.go
+++ b/client/go/cmd/cert.go
@@ -22,10 +22,11 @@ func init() {
}
var certCmd = &cobra.Command{
- Use: "cert",
- Short: "Create a new private key and self-signed certificate for Vespa Cloud deployment",
- Example: "$ vespa cert -a my-tenant.my-app.my-instance",
- Args: cobra.MaximumNArgs(1),
+ Use: "cert",
+ Short: "Create a new private key and self-signed certificate for Vespa Cloud deployment",
+ Example: "$ vespa cert -a my-tenant.my-app.my-instance",
+ DisableAutoGenTag: true,
+ Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
app := getApplication()
pkg, err := vespa.ApplicationPackageFrom(applicationSource(args))
diff --git a/client/go/cmd/clone.go b/client/go/cmd/clone.go
index 39281d408a5..ffd77030935 100644
--- a/client/go/cmd/clone.go
+++ b/client/go/cmd/clone.go
@@ -36,7 +36,8 @@ var cloneCmd = &cobra.Command{
Example: "$ vespa clone vespa-cloud/album-recommendation my-app",
The application package is copied from a sample application in https://github.com/vespa-engine/sample-apps`,
- Args: cobra.ExactArgs(2),
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
cloneApplication(args[0], args[1])
},
diff --git a/client/go/cmd/config.go b/client/go/cmd/config.go
index 56d4321c11d..bb1662d0b07 100644
--- a/client/go/cmd/config.go
+++ b/client/go/cmd/config.go
@@ -32,8 +32,9 @@ func init() {
}
var configCmd = &cobra.Command{
- Use: "config",
- Short: "Configure default values for flags",
+ Use: "config",
+ Short: "Configure default values for flags",
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
// Root command does nothing
cmd.Help()
@@ -42,10 +43,11 @@ var configCmd = &cobra.Command{
}
var setConfigCmd = &cobra.Command{
- Use: "set <option> <value>",
- Short: "Set a configuration option.",
- Example: "$ vespa config set target cloud",
- Args: cobra.ExactArgs(2),
+ Use: "set <option> <value>",
+ Short: "Set a configuration option.",
+ Example: "$ vespa config set target cloud",
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
if err := setOption(args[0], args[1]); err != nil {
log.Print(err)
@@ -56,10 +58,11 @@ var setConfigCmd = &cobra.Command{
}
var getConfigCmd = &cobra.Command{
- Use: "get [<option>]",
- Short: "Get a configuration option",
- Example: "$ vespa config get target",
- Args: cobra.MaximumNArgs(1),
+ Use: "get [<option>]",
+ Short: "Get a configuration option",
+ Example: "$ vespa config get target",
+ Args: cobra.MaximumNArgs(1),
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 { // Print all values
printOption(targetFlag)
diff --git a/client/go/cmd/deploy.go b/client/go/cmd/deploy.go
index 4cd542898da..f44d3aeae42 100644
--- a/client/go/cmd/deploy.go
+++ b/client/go/cmd/deploy.go
@@ -42,8 +42,9 @@ and activated on config servers. The process of applying it on individual nodes
has started but may not have completed.
If application directory is not specified, it defaults to working directory.`,
- Example: "$ vespa deploy .",
- Args: cobra.MaximumNArgs(1),
+ Example: "$ vespa deploy .",
+ Args: cobra.MaximumNArgs(1),
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
pkg, err := vespa.ApplicationPackageFrom(applicationSource(args))
if err != nil {
@@ -74,9 +75,10 @@ If application directory is not specified, it defaults to working directory.`,
}
var prepareCmd = &cobra.Command{
- Use: "prepare <application-directory>",
- Short: "Prepare an application package for activation",
- Args: cobra.MaximumNArgs(1),
+ Use: "prepare <application-directory>",
+ Short: "Prepare an application package for activation",
+ Args: cobra.MaximumNArgs(1),
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
pkg, err := vespa.ApplicationPackageFrom(applicationSource(args))
if err != nil {
@@ -102,9 +104,10 @@ var prepareCmd = &cobra.Command{
}
var activateCmd = &cobra.Command{
- Use: "activate",
- Short: "Activate (deploy) a previously prepared application package",
- Args: cobra.MaximumNArgs(1),
+ Use: "activate",
+ Short: "Activate (deploy) a previously prepared application package",
+ Args: cobra.MaximumNArgs(1),
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
pkg, err := vespa.ApplicationPackageFrom(applicationSource(args))
if err != nil {
diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go
index daea27a0815..8a438ad4125 100644
--- a/client/go/cmd/document.go
+++ b/client/go/cmd/document.go
@@ -34,8 +34,9 @@ subsequent get or query operation.
To feed with high throughput, https://docs.vespa.ai/en/vespa-feed-client.html
should be used instead of this.`,
- Example: `$ vespa document src/test/resources/A-Head-Full-of-Dreams.json`,
- Args: cobra.ExactArgs(1),
+ Example: `$ vespa document src/test/resources/A-Head-Full-of-Dreams.json`,
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
printResult(vespa.Send(args[0], documentService()), false)
},
@@ -50,6 +51,7 @@ If the document id is specified both as an argument and in the file the argument
Args: cobra.RangeArgs(1, 2),
Example: `$ vespa document put src/test/resources/A-Head-Full-of-Dreams.json
$ vespa document put id:mynamespace:music::a-head-full-of-dreams src/test/resources/A-Head-Full-of-Dreams.json`,
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 1 {
printResult(vespa.Put("", args[0], documentService()), false)
@@ -67,6 +69,7 @@ If the document id is specified both as an argument and in the file the argument
Args: cobra.RangeArgs(1, 2),
Example: `$ vespa document update src/test/resources/A-Head-Full-of-Dreams-Update.json
$ vespa document update id:mynamespace:music::a-head-full-of-dreams src/test/resources/A-Head-Full-of-Dreams.json`,
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 1 {
printResult(vespa.Update("", args[0], documentService()), false)
@@ -84,6 +87,7 @@ If the document id is specified both as an argument and in the file the argument
Args: cobra.ExactArgs(1),
Example: `$ vespa document remove src/test/resources/A-Head-Full-of-Dreams-Remove.json
$ vespa document remove id:mynamespace:music::a-head-full-of-dreams`,
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
if strings.HasPrefix(args[0], "id:") {
printResult(vespa.RemoveId(args[0], documentService()), false)
@@ -94,9 +98,10 @@ $ vespa document remove id:mynamespace:music::a-head-full-of-dreams`,
}
var documentGetCmd = &cobra.Command{
- Use: "get <id>",
- Short: "Gets a document",
- Args: cobra.ExactArgs(1),
+ Use: "get <id>",
+ Short: "Gets a document",
+ Args: cobra.ExactArgs(1),
+ DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
printResult(vespa.Get(args[0], documentService()), true)
},
diff --git a/client/go/cmd/man.go b/client/go/cmd/man.go
new file mode 100644
index 00000000000..0bd80f3d985
--- /dev/null
+++ b/client/go/cmd/man.go
@@ -0,0 +1,27 @@
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+ "github.com/spf13/cobra/doc"
+)
+
+func init() {
+ rootCmd.AddCommand(manCmd)
+}
+
+var manCmd = &cobra.Command{
+ Use: "man <directory>",
+ Short: "Generate man pages and write them to given directory",
+ Args: cobra.ExactArgs(1),
+ Hidden: true, // Not intended to be called by users
+ DisableAutoGenTag: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ dir := args[0]
+ err := doc.GenManTree(rootCmd, nil, dir)
+ if err != nil {
+ fatalErr(err, "Failed to write man pages")
+ return
+ }
+ printSuccess("Man pages written to ", dir)
+ },
+}
diff --git a/client/go/cmd/man_test.go b/client/go/cmd/man_test.go
new file mode 100644
index 00000000000..59efc64b8de
--- /dev/null
+++ b/client/go/cmd/man_test.go
@@ -0,0 +1,17 @@
+package cmd
+
+import (
+ "fmt"
+ "path/filepath"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/vespa-engine/vespa/client/go/util"
+)
+
+func TestMan(t *testing.T) {
+ tmpDir := t.TempDir()
+ out := execute(command{args: []string{"man", tmpDir}}, t, nil)
+ assert.Equal(t, fmt.Sprintf("Success: Man pages written to %s\n", tmpDir), out)
+ assert.True(t, util.PathExists(filepath.Join(tmpDir, "vespa.1")))
+}
diff --git a/client/go/cmd/query.go b/client/go/cmd/query.go
index 778873b6818..062ea8d1bbc 100644
--- a/client/go/cmd/query.go
+++ b/client/go/cmd/query.go
@@ -28,7 +28,8 @@ var queryCmd = &cobra.Command{
Any parameter from https://docs.vespa.ai/en/reference/query-api-reference.html
can be set by the syntax [parameter-name]=[value].`,
// TODO: Support referencing a query json file
- Args: cobra.MinimumNArgs(1),
+ DisableAutoGenTag: true,
+ Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
query(args)
},
diff --git a/client/go/cmd/root.go b/client/go/cmd/root.go
index b4ffd9c262c..fde7d6edb5a 100644
--- a/client/go/cmd/root.go
+++ b/client/go/cmd/root.go
@@ -26,7 +26,9 @@ Use it on Vespa instances running locally, remotely or in the cloud.
Prefer web service API's to this in production.
Vespa documentation: https://docs.vespa.ai`,
+ DisableAutoGenTag: true,
}
+
color aurora.Aurora
targetArg string
applicationArg string
diff --git a/client/go/cmd/status.go b/client/go/cmd/status.go
index 8764cddbb91..796ede9c86d 100644
--- a/client/go/cmd/status.go
+++ b/client/go/cmd/status.go
@@ -16,40 +16,44 @@ func init() {
}
var statusCmd = &cobra.Command{
- Use: "status",
- Short: "Verify that a service is ready to use (query by default)",
- Example: `$ vespa status query`,
- Args: cobra.MaximumNArgs(1),
+ Use: "status",
+ Short: "Verify that a service is ready to use (query by default)",
+ Example: `$ vespa status query`,
+ DisableAutoGenTag: true,
+ Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
waitForService("query")
},
}
var statusQueryCmd = &cobra.Command{
- Use: "query",
- Short: "Verify that the query service is ready to use (default)",
- Example: `$ vespa status query`,
- Args: cobra.ExactArgs(0),
+ Use: "query",
+ Short: "Verify that the query service is ready to use (default)",
+ Example: `$ vespa status query`,
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
waitForService("query")
},
}
var statusDocumentCmd = &cobra.Command{
- Use: "document",
- Short: "Verify that the document service is ready to use",
- Example: `$ vespa status document`,
- Args: cobra.ExactArgs(0),
+ Use: "document",
+ Short: "Verify that the document service is ready to use",
+ Example: `$ vespa status document`,
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
waitForService("document")
},
}
var statusDeployCmd = &cobra.Command{
- Use: "deploy",
- Short: "Verify that the deploy service is ready to use",
- Example: `$ vespa status deploy`,
- Args: cobra.ExactArgs(0),
+ Use: "deploy",
+ Short: "Verify that the deploy service is ready to use",
+ Example: `$ vespa status deploy`,
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
waitForService("deploy")
},
diff --git a/client/go/cmd/version.go b/client/go/cmd/version.go
index c9146fc1f92..4a5b6ec71b3 100644
--- a/client/go/cmd/version.go
+++ b/client/go/cmd/version.go
@@ -12,9 +12,10 @@ func init() {
}
var versionCmd = &cobra.Command{
- Use: "version",
- Short: "Show version number",
- Args: cobra.ExactArgs(0),
+ Use: "version",
+ Short: "Show version number",
+ DisableAutoGenTag: true,
+ Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
log.Print("vespa version ", build.Version)
},
diff --git a/client/go/go.sum b/client/go/go.sum
index cec273d1506..826f137d5e2 100644
--- a/client/go/go.sum
+++ b/client/go/go.sum
@@ -55,6 +55,7 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
+github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -209,9 +210,11 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=