keywords

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "keywords <query>",
	Aliases: []string{"k", "kw", "key", "keyword"},
	Args:    cobra.ExactArgs(1),
	Short:   "Search for permissible names for platform, instrument, and provider",
	Long: `

Using this search can be hit-or-miss, as not all platforms, instruments, and 
providers are registered. However, it can be useful for those that are registered 
if you know a few keywords regarding what you're looking for. 

For example, if you need to know the name of the Suomi-NPP platform (sometimes 
referred to as NPP) you can perform a search using the query "npp" to get the
correct value.
  `,
	RunE: func(cmd *cobra.Command, args []string) error {
		verbose, err := cmd.Flags().GetBool("verbose")
		failOnError(err)

		var logger *log.Logger
		if verbose {
			logger = log.New(os.Stderr, "", log.LstdFlags)
		}

		api := internal.NewCMRSearchAPI(logger)

		zult, err := api.SearchFacets(context.Background(), args[0], nil)
		if err != nil {
			log.Fatalf("Failed! %s", err)
		}

		t := table.NewWriter()
		t.SetStyle(table.StyleLight)
		t.SetOutputMirror(os.Stdout)
		t.AppendHeader(table.Row{"Type", "Value", "Score", "Fields"})

		for facet := range zult.Ch {
			t.AppendRow(table.Row{facet.Type, elipsis(facet.Value, 48), facet.Score, elipsis(facet.Fields, 48)})
		}
		t.Render()

		if err := zult.Err(); err != nil {
			log.Fatalf("ERROR: %s", err)
		}

		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