示例#1
0
func docPlugin(c *cli.Context) {
	if len(c.Args()) != 1 {
		fmt.Printf("Which documentation do you want to open? Try 'apiplexy plugin-doc <plugin-name>'.\n")
		os.Exit(1)
	}
	plugin, ok := apiplexy.AvailablePlugins()[c.Args()[0]]
	if !ok {
		fmt.Printf("Plugin '%s' not found. Try 'apiplexy plugins' to list available ones.\n", c.Args()[0])
		os.Exit(1)
	}
	fmt.Printf("Opening documentation for '%s' at: %s\n", plugin.Name, plugin.Link)
	open.Start(plugin.Link)
}
示例#2
0
func listPlugins(c *cli.Context) {
	fmt.Printf("Available plugins:\n\n")
	avail := apiplexy.AvailablePlugins()
	pnames := make([]string, len(avail))
	i := 0
	for n, _ := range avail {
		pnames[i] = n
		i++
	}
	sort.Strings(pnames)

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 0, 8, 0, '\t', 0)
	for _, name := range pnames {
		plugin := avail[name]
		fmt.Fprintf(w, "   %s\t %s\n", name, plugin.Description)
	}
	fmt.Fprintln(w)
	w.Flush()
}