|
| 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 | +} |
0 commit comments