cmd

package
v0.0.0-...-11a2f96 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:           "scrappy",
	Short:         "Scrappy is a tool for scraping web pages",
	SilenceUsage:  true,
	SilenceErrors: true,

	PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
		if err := viper.BindPFlags(cmd.PersistentFlags()); err != nil {
			return err
		}
		viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
		viper.AutomaticEnv()
		viper.SetEnvPrefix("SCRAPPY")
		viper.AddConfigPath(".")
		viper.SetConfigName("env")
		err := viper.ReadInConfig()
		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
			fmt.Printf("Error reading config file %v\n", err)
			return err
		}
		return nil
	},

	RunE: func(cmd *cobra.Command, _ []string) error {
		logger := logger.CreateLogger()
		args, err := config.New()
		if err != nil {
			logger.Infof("Error: %v", err)
			return err
		}
		return startMainLoop(&args, logger)
	},
}

Functions

func Contains

func Contains[T comparable](s []T, e T) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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