forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
man.go
36 lines (31 loc) · 722 Bytes
/
man.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2019 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// man - print manual entry for command.
//
// Synopsis:
// man COMMAND
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"github.com/u-root/u-root/cmds/core/man/data"
)
//go:generate go run gen/gen.go ../../../cmds data/data.go
func main() {
if len(os.Args) != 2 {
log.Fatal("Usage: man COMMAND")
}
mans := make(map[string]string)
if err := json.Unmarshal([]byte(data.Data), &mans); err != nil {
log.Fatal(err)
}
cmd := os.Args[1]
man, ok := mans[cmd]
if !ok {
log.Fatalf("No manual entry for %q", cmd)
}
fmt.Println(man)
}