collections

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "collections",
	Aliases: []string{"c", "col", "collection"},
	Short:   "Search for and discover Collections",
	Example: `
  Search for all collections by short name prefix:

    cmrfetch collections -s "CLDMSK_*"

  Search for multiple collection short names:

    cmrfetch collections -s CLDMSK_L2_VIIRS_SNPP -s CLDMSK_L2_VIIRS_NOAA20,CLDMSK_L2_MODIS_Aqua

  Search for a collection by keyword:

    cmrfetch collections -k aerdt

  Search for a collection by platform:

    cmrfetch collections -p Suomi-NPP
`,
	RunE: func(cmd *cobra.Command, args []string) error {
		flags := cmd.Flags()

		output, err := flags.GetString("output")
		failOnError(err)

		params, err := newParams(flags)
		if err != nil {
			return err
		}

		verbose, err := flags.GetBool("verbose")
		failOnError(err)

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

		var writer outputWriter
		switch output {
		case "brief":
			writer = tableWriter
		case "short":
			writer = shortWriter
		case "long":
			writer = longWriter
		default:
			return fmt.Errorf("--output must be one of brief, short or long")
		}

		if !haveFilterFlags(flags) {
			return fmt.Errorf("at least one of %s is required", requiredFlags())
		}

		return do(api, params, writer)
	},
}

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