Esempio n. 1
0
// 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)
}
Esempio n. 2
0
File: docs.go Progetto: 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)
}
Esempio n. 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)
	}
}