download

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "download [stream] [snapshot] <file>",
	Short: "Download a feed snapshot to a Parquet file",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) >= 1 && len(args) <= 3 {
			return nil
		}
		return fmt.Errorf("accepts <file>, <stream> <file>, or <stream> <snapshot> <file>")
	},
	Run: func(cmd *cobra.Command, args []string) {
		config, err := conf.Read()
		if err != nil {
			app.Fatal(err, "failed to read configuration file")
		}

		client, err := auth.SynthientClient(config)
		if err != nil {
			app.Fatal(err, "failed to create synthient client")
		}
		config.ApplyToClient(&client)

		var (
			streamName = "anonymizers"
			filename   = args[0]
			snapshot   = snapshotFromFlags()
		)
		if len(args) == 2 {
			streamName = args[0]
			filename = args[1]
		} else if len(args) == 3 {
			streamName = args[0]
			snapshot = args[1]
			filename = args[2]
		}
		stream, ok := feed.Find(streamName)
		if !ok {
			timber.FatalMsg("unknown stream", timber.A("value", streamName), timber.A("valid", feed.Names()))
		}

		if !flags.noPreflight {
			err = access.Require(client, access.Required(stream, "feed"))
			if err != nil {
				app.Fatal(err, "failed feed access preflight")
			}
		}

		_, err = feeddownload.Run(feeddownload.Options{
			Client:   client,
			Stream:   stream,
			Snapshot: snapshot,
			Filename: filename,
			Force:    flags.force,
			Verify:   flags.verify,
			Quiet:    options.Quiet || flags.silent,
			Out:      os.Stdout,
		})
		if err != nil {
			app.Fatal(err, "failed to download", timber.A("file", filename), timber.A("stream", stream.Name))
		}
	},
}

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