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 12, 2021
1 parent 862cac7 commit 3f0be54
Show file tree
Hide file tree
Showing 50 changed files with 2,509 additions and 54 deletions.
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.20211128070100-3f68e679c844
github.com/dustin/go-humanize v1.0.0
github.com/spf13/cobra v0.0.5
github.com/spf13/cobra v1.2.1
)
581 changes: 559 additions & 22 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)
}
68 changes: 68 additions & 0 deletions man/obs-cli-completion-bash.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.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:
$ source <(obs\-cli completion bash)

.PP
To load completions for every new session, execute once:
Linux:
$ obs\-cli completion bash > /etc/bash\_completion.d/obs\-cli
MacOS:
$ obs\-cli completion bash > /usr/local/etc/bash\_completion.d/obs\-cli

.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
12\-Dec\-2021 Auto generated by spf13/cobra
61 changes: 61 additions & 0 deletions man/obs-cli-completion-fish.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.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:
$ obs\-cli completion fish | source

.PP
To load completions for every new session, execute once:
$ obs\-cli completion fish > \~/.config/fish/completions/obs\-cli.fish

.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
12\-Dec\-2021 Auto generated by spf13/cobra
58 changes: 58 additions & 0 deletions man/obs-cli-completion-powershell.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.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:
PS C:> obs\-cli completion powershell | Out\-String | Invoke\-Expression

.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
12\-Dec\-2021 Auto generated by spf13/cobra
73 changes: 73 additions & 0 deletions man/obs-cli-completion-zsh.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.nh
.TH "OBS\-CLI\-COMPLETION\-ZSH" "1" "Dec 2021" "Auto generated by muesli/obs\-cli" ""

.SH NAME
.PP
obs\-cli\-completion\-zsh \- generate the autocompletion script for zsh


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


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

.PP
If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:

.PP
$ echo "autoload \-U compinit; compinit" >> \~/.zshrc

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


.SH Linux:
.PP
$ obs\-cli completion zsh > "${fpath[1]}/\_obs\-cli"


.SH macOS:
.PP
$ obs\-cli completion zsh > /usr/local/share/zsh/site\-functions/\_obs\-cli

.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 zsh

.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
12\-Dec\-2021 Auto generated by spf13/cobra
47 changes: 47 additions & 0 deletions man/obs-cli-completion.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.nh
.TH "OBS\-CLI\-COMPLETION" "1" "Dec 2021" "Auto generated by muesli/obs\-cli" ""

.SH NAME
.PP
obs\-cli\-completion \- generate the autocompletion script for the specified shell


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


.SH DESCRIPTION
.PP
Generate the autocompletion script for obs\-cli for the specified shell.
See each sub\-command's help for details on how to use the generated script.


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


.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(1)\fP, \fBobs\-cli\-completion\-bash(1)\fP, \fBobs\-cli\-completion\-fish(1)\fP, \fBobs\-cli\-completion\-powershell(1)\fP, \fBobs\-cli\-completion\-zsh(1)\fP


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

0 comments on commit 3f0be54

Please sign in to comment.