Skip to content

Commit

Permalink
Generate man pages with hidden 'man' command
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Dec 17, 2021
1 parent 912165f commit fc6312e
Show file tree
Hide file tree
Showing 72 changed files with 3,567 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build:
strategy:
matrix:
go-version: [~1.11, ^1]
go-version: [~1.12, ^1]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages.
### Build From Source

Alternatively you can also build `obs-cli` from source. Make sure you have a
working Go environment (Go 1.11 or higher is required). See the
working Go environment (Go 1.12 or higher is required). See the
[install instructions](https://golang.org/doc/install.html).

To install obs-cli, simply run:
Expand Down Expand Up @@ -232,3 +232,11 @@ Display virtual camera status:
```
obs-cli virtualcam status
```

## Development

You can regenerate the man pages with:

```
go run -tags man . man ./man
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.13
require (
github.com/andreykaipov/goobs v0.7.2-0.20211214043459-295018585403
github.com/dustin/go-humanize v1.0.0
github.com/spf13/cobra v0.0.5
github.com/spf13/cobra v1.3.0
)
769 changes: 748 additions & 21 deletions go.sum

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions label.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (

var (
labelCmd = &cobra.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 = &cobra.Command{
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func main() {
}

func init() {
cobra.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")
Expand All @@ -49,6 +48,10 @@ func getUserAgent() string {
return userAgent
}

func connectOBSCommand(cmd *cobra.Command, args []string) {
connectOBS()
}

func connectOBS() {
var err error
client, err = goobs.New(
Expand Down
39 changes: 39 additions & 0 deletions man.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//go:build man
// +build man

package main

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var (
manCmd = &cobra.Command{
Use: "man [directory]",
Short: "Generates manpages",
Long: `Generates manpages in the given directory`,
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("man needs a target directory")
}
return generateManPages(args[0])
},
}
)

func init() {
rootCmd.AddCommand(manCmd)
}

func generateManPages(targetDirectory string) error {
header := &doc.GenManHeader{
Section: "1",
Source: "Auto generated by muesli/obs-cli",
}

return doc.GenManTree(rootCmd, header, targetDirectory)
}
92 changes: 92 additions & 0 deletions man/obs-cli-completion-bash.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.nh
.TH "OBS-CLI-COMPLETION-BASH" "1" "Dec 2021" "Auto generated by muesli/obs-cli" ""

.SH NAME
.PP
obs-cli-completion-bash - Generate the autocompletion script for bash


.SH SYNOPSIS
.PP
\fBobs-cli completion bash\fP


.SH DESCRIPTION
.PP
Generate the autocompletion script for the bash shell.

.PP
This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager.

.PP
To load completions in your current shell session:

.PP
.RS

.nf
source <(obs-cli completion bash)

.fi
.RE

.PP
To load completions for every new session, execute once:

.SS Linux:
.PP
.RS

.nf
obs-cli completion bash > /etc/bash_completion.d/obs-cli

.fi
.RE

.SS macOS:
.PP
.RS

.nf
obs-cli completion bash > /usr/local/etc/bash_completion.d/obs-cli

.fi
.RE

.PP
You will need to start a new shell for this setup to take effect.


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for bash

.PP
\fB--no-descriptions\fP[=false]
disable completion descriptions


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--host\fP="localhost"
host to connect to

.PP
\fB--password\fP=""
password for connection

.PP
\fB-p\fP, \fB--port\fP=4444
port to connect to


.SH SEE ALSO
.PP
\fBobs-cli-completion(1)\fP


.SH HISTORY
.PP
17-Dec-2021 Auto generated by spf13/cobra
77 changes: 77 additions & 0 deletions man/obs-cli-completion-fish.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.nh
.TH "OBS-CLI-COMPLETION-FISH" "1" "Dec 2021" "Auto generated by muesli/obs-cli" ""

.SH NAME
.PP
obs-cli-completion-fish - Generate the autocompletion script for fish


.SH SYNOPSIS
.PP
\fBobs-cli completion fish [flags]\fP


.SH DESCRIPTION
.PP
Generate the autocompletion script for the fish shell.

.PP
To load completions in your current shell session:

.PP
.RS

.nf
obs-cli completion fish | source

.fi
.RE

.PP
To load completions for every new session, execute once:

.PP
.RS

.nf
obs-cli completion fish > ~/.config/fish/completions/obs-cli.fish

.fi
.RE

.PP
You will need to start a new shell for this setup to take effect.


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for fish

.PP
\fB--no-descriptions\fP[=false]
disable completion descriptions


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--host\fP="localhost"
host to connect to

.PP
\fB--password\fP=""
password for connection

.PP
\fB-p\fP, \fB--port\fP=4444
port to connect to


.SH SEE ALSO
.PP
\fBobs-cli-completion(1)\fP


.SH HISTORY
.PP
17-Dec-2021 Auto generated by spf13/cobra
66 changes: 66 additions & 0 deletions man/obs-cli-completion-powershell.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.nh
.TH "OBS-CLI-COMPLETION-POWERSHELL" "1" "Dec 2021" "Auto generated by muesli/obs-cli" ""

.SH NAME
.PP
obs-cli-completion-powershell - Generate the autocompletion script for powershell


.SH SYNOPSIS
.PP
\fBobs-cli completion powershell [flags]\fP


.SH DESCRIPTION
.PP
Generate the autocompletion script for powershell.

.PP
To load completions in your current shell session:

.PP
.RS

.nf
obs-cli completion powershell | Out-String | Invoke-Expression

.fi
.RE

.PP
To load completions for every new session, add the output of the above command
to your powershell profile.


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for powershell

.PP
\fB--no-descriptions\fP[=false]
disable completion descriptions


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--host\fP="localhost"
host to connect to

.PP
\fB--password\fP=""
password for connection

.PP
\fB-p\fP, \fB--port\fP=4444
port to connect to


.SH SEE ALSO
.PP
\fBobs-cli-completion(1)\fP


.SH HISTORY
.PP
17-Dec-2021 Auto generated by spf13/cobra
Loading

0 comments on commit fc6312e

Please sign in to comment.