Repository: authzed/spicedb (Go)

Issue:
Write or generate man-page
SpiceDB does ship with a fairly in-depth usage, `--help`, and shell completion, but it does not ship a man-page.

This could be hand-written or generated from our flag library. [Mango](https://github.com/muesli/mango) looks like a good library we could use to generate it from our usage of Cobra.


Discussion:
I might be able to help with this one, could I be assigned? 



Patch:
diff --git a/.gitignore b/.gitignore
index 0b3930b32..492fc6a87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 dist/
 completions/
+manpages/
 *.wasm
 .vscode/settings.json
 .env.local
diff --git a/.goreleaser.yml b/.goreleaser.yml
index 07f46e3a3..76ad8cc26 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -7,6 +7,7 @@ git:
 before:
   hooks:
     - "go run mage.go gen:completions"
+    - "go run mage.go gen:manpages"
 builds:
   - main: "./cmd/spicedb"
     env:
@@ -26,6 +27,7 @@ archives:
       - "README.md"
       - "LICENSE"
       - "completions/*"
+      - "manpages/*"
 nfpms:
   - vendor: "authzed inc."
     homepage: "https://spicedb.io"
@@ -50,6 +52,10 @@ nfpms:
         dst: "/usr/share/zsh/vendor-completions/_spicedb"
         file_info:
           mode: 0644
+      - src: "./manpages/spicedb.1"
+        dst: "/usr/share/man/man1/spicedb.1"
+        file_info:
+          mode: 0644
 furies:
   - account: "authzed"
     secret_name: "GEMFURY_PUSH_TOKEN"
diff --git a/cmd/spicedb/main.go b/cmd/spicedb/main.go
index 94d23d53b..9b1b3cc0d 100644
--- a/cmd/spicedb/main.go
+++ b/cmd/spicedb/main.go
@@ -85,11 +85,16 @@ func buildRootCommand() (*cobra.Command, error) {
 	rootCmd.AddCommand(testingCmd)
 
 	rootCmd.AddCommand(&cobra.Command{
-		Use:                   "man",
-		Short:                 "Generate the SpiceDB manpage",
+		Use:   "man",
+		Short: "Generate man page",
+		Long: `Generate a man page for SpiceDB.
+
+The output can be redirected to a file and installed to the system:
+  spicedb man > spicedb.1
+  sudo mv spicedb.1 /usr/share/man/man1/
+  sudo mandb  # Update man page database`,
 		SilenceUsage:          true,
 		DisableFlagsInUseLine: true,
-		Hidden:                true,
 		Args:                  cobra.NoArgs,
 		RunE: func(cmd *cobra.Command, args []string) error {
 			manPage, err := mcobra.NewManPage(1, cmd.Root())
diff --git a/magefiles/gen.go b/magefiles/gen.go
index 38ba660ea..08e644a86 100644
--- a/magefiles/gen.go
+++ b/magefiles/gen.go
@@ -49,3 +49,19 @@ func (Gen) Completions() error {
 	}
 	return nil
 }
+
+// Manpages Generate man pages
+func (Gen) Manpages() error {
+	if err := RunSh("mkdir", WithDir("."))("-p", "./manpages"); err != nil {
+		return err
+	}
+
+	f, err := os.Create("./manpages/spicedb.1")
+	if err != nil {
+		return err
+	}
+	defer f.Close()
+
+	fmt.Println("generating man page")
+	return RunSh("go", WithDir("."), WithStdout(f))("run", "./cmd/spicedb/main.go", "man")
+}


Test patch:
diff --git a/cmd/spicedb/main_test.go b/cmd/spicedb/main_test.go
index 100f9b2d6..7936b06d0 100644
--- a/cmd/spicedb/main_test.go
+++ b/cmd/spicedb/main_test.go
@@ -42,10 +42,10 @@ func TestMainCommandStructure(t *testing.T) {
 	require.NoError(t, err)
 	require.True(t, migrateCmd.Hidden)
 
-	// Verify man command is hidden
+	// Verify man command is visible (not hidden)
 	manCmd, _, err := rootCmd.Find([]string{"man"})
 	require.NoError(t, err)
-	require.True(t, manCmd.Hidden)
+	require.False(t, manCmd.Hidden)
 }
 
 func TestMainCommandFlagErrorFunc(t *testing.T) {