Move manpage gen to separate binary

This moves the man page generation to a separate binary

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2019-09-12 14:18:09 -04:00
parent 9c77ec3c73
commit 5a656cacb4
6 changed files with 59 additions and 86 deletions

View File

@@ -30,7 +30,6 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/climan"
"github.com/containerd/containerd/plugin"
metrics "github.com/docker/go-metrics"
"github.com/sirupsen/logrus"
@@ -162,7 +161,6 @@ func main() {
}
app.Commands = []cli.Command{
densityCommand,
climan.Command,
}
app.Action = func(context *cli.Context) error {
config := config{

View File

@@ -21,7 +21,6 @@ import (
"os"
"github.com/containerd/containerd/cmd/containerd/command"
"github.com/containerd/containerd/pkg/climan"
"github.com/containerd/containerd/pkg/seed"
)
@@ -31,7 +30,6 @@ func init() {
func main() {
app := command.App()
app.Commands = append(app.Commands, climan.Command)
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "containerd: %s\n", err)
os.Exit(1)

View File

@@ -21,7 +21,6 @@ import (
"os"
"github.com/containerd/containerd/cmd/ctr/app"
"github.com/containerd/containerd/pkg/climan"
"github.com/containerd/containerd/pkg/seed"
"github.com/urfave/cli"
)
@@ -35,7 +34,6 @@ func init() {
func main() {
app := app.New()
app.Commands = append(app.Commands, pluginCmds...)
app.Commands = append(app.Commands, climan.Command)
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
os.Exit(1)

57
cmd/gen-manpages/main.go Normal file
View File

@@ -0,0 +1,57 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/containerd/containerd/cmd/containerd/command"
"github.com/containerd/containerd/cmd/ctr/app"
"github.com/urfave/cli"
)
func main() {
if err := run(); err != nil {
fmt.Fprint(os.Stderr, err)
os.Exit(1)
}
}
func run() error {
flag.Parse()
apps := map[string]*cli.App{
"containerd": command.App(),
"ctr": app.New(),
}
dir := flag.Arg(0)
for name, app := range apps {
// clear out the usage as we use banners that do not display in man pages
app.Usage = ""
data, err := app.ToMan()
if err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
return err
}
}
return nil
}