Skip to content

Commit 9741f03

Browse files
authored
Merge pull request #3648 from crosbymichael/man-bin
Move manpage gen to separate binary
2 parents 9c77ec3 + 5a656ca commit 9741f03

6 files changed

Lines changed: 59 additions & 86 deletions

File tree

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ TEST_REQUIRES_ROOT_PACKAGES=$(filter \
8282

8383
# Project binaries.
8484
COMMANDS=ctr containerd containerd-stress
85-
MANBINARIES=ctr containerd containerd-stress
8685
MANPAGES=ctr.1 containerd.1 containerd-config.1 containerd-config.toml.5
8786

8887
ifdef BUILDTAGS
@@ -204,10 +203,8 @@ man: mandir $(addprefix man/,$(MANPAGES))
204203
mandir:
205204
@mkdir -p man
206205

207-
genman: $(addprefix genman/,$(MANBINARIES))
208-
209-
genman/%: bin/% FORCE
210-
"$<" gen-man --format man man/
206+
genman: FORCE
207+
go run cmd/gen-manpages/main.go man/
211208

212209
man/%: docs/man/%.md FORCE
213210
@echo "$(WHALE) $<"

cmd/containerd-stress/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030

3131
"github.com/containerd/containerd"
3232
"github.com/containerd/containerd/namespaces"
33-
"github.com/containerd/containerd/pkg/climan"
3433
"github.com/containerd/containerd/plugin"
3534
metrics "github.com/docker/go-metrics"
3635
"github.com/sirupsen/logrus"
@@ -162,7 +161,6 @@ func main() {
162161
}
163162
app.Commands = []cli.Command{
164163
densityCommand,
165-
climan.Command,
166164
}
167165
app.Action = func(context *cli.Context) error {
168166
config := config{

cmd/containerd/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"os"
2222

2323
"github.com/containerd/containerd/cmd/containerd/command"
24-
"github.com/containerd/containerd/pkg/climan"
2524
"github.com/containerd/containerd/pkg/seed"
2625
)
2726

@@ -31,7 +30,6 @@ func init() {
3130

3231
func main() {
3332
app := command.App()
34-
app.Commands = append(app.Commands, climan.Command)
3533
if err := app.Run(os.Args); err != nil {
3634
fmt.Fprintf(os.Stderr, "containerd: %s\n", err)
3735
os.Exit(1)

cmd/ctr/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"os"
2222

2323
"github.com/containerd/containerd/cmd/ctr/app"
24-
"github.com/containerd/containerd/pkg/climan"
2524
"github.com/containerd/containerd/pkg/seed"
2625
"github.com/urfave/cli"
2726
)
@@ -35,7 +34,6 @@ func init() {
3534
func main() {
3635
app := app.New()
3736
app.Commands = append(app.Commands, pluginCmds...)
38-
app.Commands = append(app.Commands, climan.Command)
3937
if err := app.Run(os.Args); err != nil {
4038
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
4139
os.Exit(1)

cmd/gen-manpages/main.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"flag"
21+
"fmt"
22+
"io/ioutil"
23+
"os"
24+
"path/filepath"
25+
26+
"github.com/containerd/containerd/cmd/containerd/command"
27+
"github.com/containerd/containerd/cmd/ctr/app"
28+
"github.com/urfave/cli"
29+
)
30+
31+
func main() {
32+
if err := run(); err != nil {
33+
fmt.Fprint(os.Stderr, err)
34+
os.Exit(1)
35+
}
36+
}
37+
38+
func run() error {
39+
flag.Parse()
40+
apps := map[string]*cli.App{
41+
"containerd": command.App(),
42+
"ctr": app.New(),
43+
}
44+
dir := flag.Arg(0)
45+
for name, app := range apps {
46+
// clear out the usage as we use banners that do not display in man pages
47+
app.Usage = ""
48+
data, err := app.ToMan()
49+
if err != nil {
50+
return err
51+
}
52+
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
53+
return err
54+
}
55+
}
56+
return nil
57+
}

pkg/climan/cli.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)