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