github.com/iotexproject/iotex-core@v1.14.1-rc1/tools/xctl/readme/docgen.go (about) 1 package main 2 3 import ( 4 "log" 5 "path/filepath" 6 "strings" 7 8 "github.com/spf13/cobra" 9 10 "github.com/iotexproject/iotex-core/ioctl/cmd" 11 "github.com/iotexproject/iotex-core/ioctl/doc" 12 ) 13 14 var xctlPath string 15 16 func main() { 17 toolName := "xctl" 18 corePath, err := filepath.Abs(".") 19 if err != nil { 20 log.Fatal(err) 21 } 22 xctlPath = filepath.Join(corePath, "tools", "xctl") 23 24 // TODO: update 'Install' part 25 preString := `# xctl 26 xctl is a command-line interface for interacting with consortium blockchain. 27 28 # Build 29 ` + "`./buildcli.sh`\n" + ` 30 31 If you want to build xctl on Windows, you need to install mingw. Package manager [Chocolatey](https://chocolatey.org/) provides an easy way to intall latest mingw. 32 ` + "`C:\\Windows\\system32> choco install mingw`\n" + ` 33 34 After this command, target bin files will be placed in ./release/ folder, upload them to 35 specific release so install-cli.sh can download them. 36 37 # Install 38 ## Install released build 39 curl --silent https://raw.githubusercontent.com/iotexproject/iotex-core/master/install-cli.sh | sh 40 41 ## Install latest build 42 curl https://raw.githubusercontent.com/iotexproject/iotex-core/master/install-cli.sh | sh -s "unstable" 43 ` 44 rootCmd := cmd.NewXctl() 45 46 linkHandler := func(c *cobra.Command, s string) string { 47 if c == rootCmd { 48 return "readme/" + s 49 } 50 if strings.Contains(s, "xctl.md") { 51 return "../README.md" 52 } 53 return s 54 } 55 56 filePrepender := func(s string) string { 57 if strings.Contains(s, "README.md") { 58 return preString 59 } 60 return "" 61 } 62 63 path := filepath.Join(xctlPath, "readme") 64 err = doc.GenMarkdownTreeCustom(rootCmd, path, toolName, xctlPath, filePrepender, linkHandler) 65 if err != nil { 66 log.Fatal(err) 67 } 68 }