yaci

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExtractCmd = &cobra.Command{
	Use:   "extract",
	Short: "Extract chain data to various output formats",
	Long:  `Extract blockchain data and output it in the specified format.`,
}
View Source
var PostgresCmd = &cobra.Command{
	Use:   "postgres [address] [flags]",
	Short: "Extract chain data to a PostgreSQL database",
	Args:  cobra.ExactArgs(1),
	RunE:  PostgresRunE,
}
View Source
var PostgresRunE = func(cmd *cobra.Command, args []string) error {
	extractConfig := config.LoadExtractConfigFromCLI()
	if err := extractConfig.Validate(); err != nil {
		return fmt.Errorf("invalid Extract configuration: %w", err)
	}

	postgresConfig := config.LoadPostgresConfigFromCLI()
	if err := postgresConfig.Validate(); err != nil {
		return fmt.Errorf("invalid PostgreSQL configuration: %w", err)
	}

	slog.Debug("Command-line arguments", "extractConfig", extractConfig, "postgresConfig", postgresConfig)

	_, err := pgxpool.ParseConfig(postgresConfig.ConnString)
	if err != nil {
		return fmt.Errorf("failed to parse PostgreSQL connection string: %w", err)
	}

	outputHandler, err := postgresql.NewPostgresOutputHandler(postgresConfig.ConnString)
	if err != nil {
		return fmt.Errorf("failed to create PostgreSQL output handler: %w", err)
	}
	defer outputHandler.Close()

	return extractor.Extract(args[0], outputHandler, extractConfig)
}
View Source
var RootCmd = &cobra.Command{
	Use:   "yaci",
	Short: "Extract chain data",
	Long:  `yaci connects to a gRPC server and extracts blockchain data.`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		logLevel := viper.GetString("logLevel")
		if err := setLogLevel(logLevel); err != nil {
			return err
		}
		slog.Debug("Application started", "version", Version)
		return nil
	},
}
View Source
var Version = "dev"

Functions

func Execute

func Execute()

Execute runs the root command.

Types

This section is empty.

Jump to

Keyboard shortcuts

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