summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2021-12-12 02:48:55 +0100
committerChristian Muehlhaeuser <muesli@gmail.com>2022-02-03 18:31:52 +0100
commitf0659919fef2f7314c4b729102da0c9755b485c7 (patch)
tree370f2f7263a7d960d791b1f1c49b03e220aa36da
parent54a374b1e8a4944f189e1105cf2fdbf144c79311 (diff)
Generate man pages with hidden 'man' commandman-pages
-rw-r--r--.github/workflows/manpage.yml38
-rw-r--r--README.md8
-rw-r--r--go.mod2
-rw-r--r--go.sum8
-rw-r--r--label.go9
-rw-r--r--main.go5
-rw-r--r--man.go41
-rw-r--r--recording.go9
-rw-r--r--scene.go9
-rw-r--r--scenecollection.go9
-rw-r--r--sceneitems.go9
-rw-r--r--sources.go9
-rw-r--r--stream.go9
-rw-r--r--studiomode.go9
-rw-r--r--virtualcam.go9
15 files changed, 146 insertions, 37 deletions
diff --git a/.github/workflows/manpage.yml b/.github/workflows/manpage.yml
new file mode 100644
index 0000000..3d00f1f
--- /dev/null
+++ b/.github/workflows/manpage.yml
@@ -0,0 +1,38 @@
+name: manpage
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ manpage:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: 1.17
+
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Download Go modules
+ run: go mod download
+
+ - name: Build
+ run: go build -v -tags mango
+
+ - name: Generate man-page
+ run: ./obs-cli man > obs-cli.1
+
+ - name: Commit
+ uses: stefanzweifel/git-auto-commit-action@v4
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ commit_message: "docs: update man page"
+ branch: master
+ commit_user_name: mango 🤖
+ commit_user_email: actions@github.com
+ commit_author: mango 🤖 <actions@github.com>
diff --git a/README.md b/README.md
index 33a1b2a..47814bb 100644
--- a/README.md
+++ b/README.md
@@ -265,3 +265,11 @@ Display virtual camera status:
```
obs-cli virtualcam status
```
+
+## Development
+
+You can regenerate the man page with:
+
+```
+go run -tags mango . man
+```
diff --git a/go.mod b/go.mod
index ab63601..e71c873 100644
--- a/go.mod
+++ b/go.mod
@@ -6,4 +6,6 @@ require (
github.com/andreykaipov/goobs v0.8.0
github.com/dustin/go-humanize v1.0.0
github.com/muesli/coral v1.0.0
+ github.com/muesli/mango-coral v1.0.1
+ github.com/muesli/roff v0.1.0
)
diff --git a/go.sum b/go.sum
index c3f780a..0961b97 100644
--- a/go.sum
+++ b/go.sum
@@ -10,6 +10,14 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/muesli/coral v1.0.0 h1:odyqkoEg4aJAINOzvnjN4tUsdp+Zleccs7tRIAkkYzU=
github.com/muesli/coral v1.0.0/go.mod h1:bf91M/dkp7iHQw73HOoR9PekdTJMTD6ihJgWoDitde8=
+github.com/muesli/mango v0.1.0 h1:DZQK45d2gGbql1arsYA4vfg4d7I9Hfx5rX/GCmzsAvI=
+github.com/muesli/mango v0.1.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
+github.com/muesli/mango-coral v1.0.1 h1:W3nGbUC/q5vLscQ6GPzteHZrJI1Msjw5Hns82o0xRkI=
+github.com/muesli/mango-coral v1.0.1/go.mod h1:EPSlYH67AtcxQrxssNw6r/lMFxHTjuDoGfq9Uxxevhg=
+github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe7Sg=
+github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
+github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
+github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
diff --git a/label.go b/label.go
index 0a61035..aea928b 100644
--- a/label.go
+++ b/label.go
@@ -9,10 +9,11 @@ import (
var (
labelCmd = &coral.Command{
- Use: "label",
- Short: "manage text labels",
- Long: `The label command manages text labels`,
- RunE: nil,
+ Use: "label",
+ Short: "manage text labels",
+ Long: `The label command manages text labels`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
textCmd = &coral.Command{
diff --git a/main.go b/main.go
index 155639d..ce51091 100644
--- a/main.go
+++ b/main.go
@@ -35,7 +35,6 @@ func main() {
}
func init() {
- coral.OnInitialize(connectOBS)
rootCmd.PersistentFlags().StringVar(&host, "host", "localhost", "host to connect to")
rootCmd.PersistentFlags().StringVar(&password, "password", "", "password for connection")
rootCmd.PersistentFlags().Uint32VarP(&port, "port", "p", 4444, "port to connect to")
@@ -49,6 +48,10 @@ func getUserAgent() string {
return userAgent
}
+func connectOBSCommand(cmd *coral.Command, args []string) {
+ connectOBS()
+}
+
func connectOBS() {
var err error
client, err = goobs.New(
diff --git a/man.go b/man.go
new file mode 100644
index 0000000..b5458ee
--- /dev/null
+++ b/man.go
@@ -0,0 +1,41 @@
+//go:build mango
+// +build mango
+
+package main
+
+import (
+ "fmt"
+
+ "github.com/muesli/coral"
+ mcoral "github.com/muesli/mango-coral"
+ "github.com/muesli/roff"
+)
+
+var (
+ manCmd = &coral.Command{
+ Use: "man [directory]",
+ Short: "Generates manpages",
+ Long: `Generates manpages in the given directory`,
+ Hidden: true,
+ RunE: func(cmd *coral.Command, args []string) error {
+ return generateManPages()
+ },
+ }
+)
+
+func init() {
+ rootCmd.AddCommand(manCmd)
+}
+
+func generateManPages() error {
+ manPage, err := mcoral.NewManPage(1, rootCmd)
+ if err != nil {
+ return err
+ }
+
+ manPage = manPage.WithSection("Copyright", "(C) 2022 Christian Muehlhaeuser.\n"+
+ "Released under MIT license.")
+
+ fmt.Println(manPage.Build(roff.NewDocument()))
+ return nil
+}
diff --git a/recording.go b/recording.go
index f4d4c3e..f73a659 100644
--- a/recording.go
+++ b/recording.go
@@ -11,10 +11,11 @@ import (
var (
recordingCmd = &coral.Command{
- Use: "recording",
- Short: "manage recordings",
- Long: `The recording command manages recordings`,
- RunE: nil,
+ Use: "recording",
+ Short: "manage recordings",
+ Long: `The recording command manages recordings`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
startStopRecordingCmd = &coral.Command{
diff --git a/scene.go b/scene.go
index 13ad3c4..be67859 100644
--- a/scene.go
+++ b/scene.go
@@ -12,10 +12,11 @@ import (
var (
sceneCmd = &coral.Command{
- Use: "scene",
- Short: "manage scenes",
- Long: `The scene command manages scenes`,
- RunE: nil,
+ Use: "scene",
+ Short: "manage scenes",
+ Long: `The scene command manages scenes`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
currentSceneCmd = &coral.Command{
diff --git a/scenecollection.go b/scenecollection.go
index 547939f..4a2ee88 100644
--- a/scenecollection.go
+++ b/scenecollection.go
@@ -11,10 +11,11 @@ import (
var (
sceneCollectionCmd = &coral.Command{
- Use: "scenecollection",
- Short: "manage scene collections",
- Long: `The scenecollection command manages scene collections`,
- RunE: nil,
+ Use: "scenecollection",
+ Short: "manage scene collections",
+ Long: `The scenecollection command manages scene collections`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
listSceneCollectionCmd = &coral.Command{
diff --git a/sceneitems.go b/sceneitems.go
index cc6d676..00d0340 100644
--- a/sceneitems.go
+++ b/sceneitems.go
@@ -11,10 +11,11 @@ import (
var (
sceneItemCmd = &coral.Command{
- Use: "sceneitem",
- Short: "manage scene items",
- Long: `The sceneitem command manages a scene's items`,
- RunE: nil,
+ Use: "sceneitem",
+ Short: "manage scene items",
+ Long: `The sceneitem command manages a scene's items`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
listSceneItemsCmd = &coral.Command{
diff --git a/sources.go b/sources.go
index 6d5c44f..4dbc209 100644
--- a/sources.go
+++ b/sources.go
@@ -10,10 +10,11 @@ import (
var (
sourceCmd = &coral.Command{
- Use: "source",
- Short: "manage sources",
- Long: `The source command manages sources`,
- RunE: nil,
+ Use: "source",
+ Short: "manage sources",
+ Long: `The source command manages sources`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
listSourcesCmd = &coral.Command{
diff --git a/stream.go b/stream.go
index ce10b4c..4b8b0fd 100644
--- a/stream.go
+++ b/stream.go
@@ -10,10 +10,11 @@ import (
var (
streamCmd = &coral.Command{
- Use: "stream",
- Short: "manage streams",
- Long: `The stream command manages streams`,
- RunE: nil,
+ Use: "stream",
+ Short: "manage streams",
+ Long: `The stream command manages streams`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
startStopStreamCmd = &coral.Command{
diff --git a/studiomode.go b/studiomode.go
index 9d07cd3..7382520 100644
--- a/studiomode.go
+++ b/studiomode.go
@@ -10,10 +10,11 @@ import (
var (
studioModeCmd = &coral.Command{
- Use: "studiomode",
- Short: "manage studio mode",
- Long: `The studiomode command manages the studio mode`,
- RunE: nil,
+ Use: "studiomode",
+ Short: "manage studio mode",
+ Long: `The studiomode command manages the studio mode`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
disableStudioModeCmd = &coral.Command{
diff --git a/virtualcam.go b/virtualcam.go
index 8dc0d2f..50ef694 100644
--- a/virtualcam.go
+++ b/virtualcam.go
@@ -9,10 +9,11 @@ import (
var (
virtualCamCmd = &coral.Command{
- Use: "virtualcam",
- Short: "manage virtual camera",
- Long: `The virtualcam command manages the virtual camera`,
- RunE: nil,
+ Use: "virtualcam",
+ Short: "manage virtual camera",
+ Long: `The virtualcam command manages the virtual camera`,
+ RunE: nil,
+ PersistentPreRun: connectOBSCommand,
}
startStopVirtualCamCmd = &coral.Command{