cmd

package
v0.0.0-...-c27bb6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "duden",
	Short: "Command line interface to http://www.duden.de",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			cmd.Help()
			os.Exit(1)
		}

		word := strings.Join(args, " ")

		opt := duden.Options{
			Timeout:     timeout,
			FollowPages: followPages,
		}

		if noColors {
			color.NoColor = true
		}

		d, err := duden.Search(word, opt)
		if err != nil {
			return err
		}

		if all {
			for _, r := range d.GetResults() {
				fmt.Printf(":: %s: %s\n", color.YellowString(r.Word), r.Definition)
			}
		} else {
			r, err := d.GetResult(pos)
			if err != nil {
				return err
			}
			fmt.Printf(":: %s: %s\n", color.YellowString(r.Word), r.Definition)
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL