示例#1
0
文件: docs.go 项目: jmcfarlane/apex
// Run command.
func run(c *cobra.Command, args []string) (err error) {
	var w io.WriteCloser = os.Stdin

	if isatty.IsTerminal(os.Stdout.Fd()) {
		cmd := exec.Command("less", "-R")
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr

		defer cmd.Wait()

		w, err = cmd.StdinPipe()
		if err != nil {
			return err
		}
		defer w.Close()

		if err := cmd.Start(); err != nil {
			return err
		}
	}

	if topic == "" {
		return wiki.Topics(w)
	}

	return wiki.Topic(topic, w)
}
示例#2
0
文件: docs.go 项目: kujohn/apex
// Run command.
func run(c *cobra.Command, args []string) error {
	if topic == "" {
		return wiki.Topics(os.Stdout)
	}

	return wiki.Topic(topic, os.Stdout)
}
示例#3
0
func wikiCmdRun(c *cobra.Command, args []string) {
	lv := &wikiCmdLocalValues

	var err error

	if lv.topic != "" {
		err = wiki.Topic(lv.topic, os.Stdout)
	} else {
		err = wiki.Topics(os.Stdout)
	}

	if err != nil {
		log.Fatalf("error: %s", err)
	}
}