cmd

package
v0.8.15 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:          "openserp",
	Short:        "Open SERP",
	Long:         `Get [Google, Yandex, Baidu] search engine results via API or CLI.`,
	Version:      version,
	SilenceUsage: true,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		err := initializeConfig(cmd)
		if err != nil {
			return err
		}
		if err := browserprofile.LoadProfilesFromJSON(config.App.ProfilesJSON); err != nil {
			return fmt.Errorf("load app.profiles: %w", err)
		}

		logFormat, err := core.NormalizeLogFormat(config.App.LogFormat)
		if err != nil {
			return err
		}
		config.App.LogFormat = logFormat

		quiet := config.Server.IsQuiet
		if commandDefaultsToQuiet(cmd) && !cmd.Flags().Changed("quiet") {
			quiet = true
		}
		config.Server.IsQuiet = quiet

		level, override, err := logLevelOverride(cmd.Flags(), config.App.LogLevel)
		if err != nil {
			return err
		}
		core.InitLogger(config.Server.IsVerbose, config.Server.IsDebug, quiet, config.App.LogFormat)
		if override {
			logrus.SetLevel(level)
		}
		logrus.WithField("config", sanitizedConfigForLog(config)).Debug("Final config")
		return nil
	},
}

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Timeout        int           `mapstructure:"timeout"`
	BrowserPath    string        `mapstructure:"browser_path"`
	ProfilesJSON   string        `mapstructure:"profiles"`
	IsBrowserHead  bool          `mapstructure:"head"`
	IsLeaveHead    bool          `mapstructure:"leave_head"`
	IsLeakless     bool          `mapstructure:"leakless"`
	BlockResources string        `mapstructure:"block_resources"`
	BlockTrackers  bool          `mapstructure:"block_trackers"`
	DebugEndpoints bool          `mapstructure:"debug_endpoints"`
	LogFormat      string        `mapstructure:"log_format"`
	LogLevel       string        `mapstructure:"log_level"`
	MaxProcesses   int           `mapstructure:"max_processes"`
	IdleTTL        time.Duration `mapstructure:"idle_ttl"`
	MegaTimeout    time.Duration `mapstructure:"mega_timeout"`
}

type CORSConfig added in v0.6.0

type CORSConfig struct {
	Enabled      bool   `mapstructure:"enabled"`
	AllowOrigins string `mapstructure:"allow_origins"`
	AllowMethods string `mapstructure:"allow_methods"`
	AllowHeaders string `mapstructure:"allow_headers"`
	MaxAge       int    `mapstructure:"max_age"`
}

type CacheConfig added in v0.6.0

type CacheConfig struct {
	TTLSeconds int `mapstructure:"ttl_seconds"`
	MaxSize    int `mapstructure:"max_size"`
}

type CaptchaConfig added in v0.7.2

type CaptchaConfig struct {
	SolverEnabled bool `mapstructure:"solver_enabled"`
}

type CircuitBreakerConfig added in v0.6.0

type CircuitBreakerConfig struct {
	Failures        int `mapstructure:"failures"`
	RecoverySeconds int `mapstructure:"recovery_seconds"`
	Successes       int `mapstructure:"successes"`
}

type Config added in v0.2.1

type Config struct {
	Server           ServerConfig         `mapstructure:"server"`
	App              AppConfig            `mapstructure:"app"`
	Proxies          core.ProxiesConfig   `mapstructure:"proxies"`
	Cache            CacheConfig          `mapstructure:"cache"`
	Extract          extractpkg.Config    `mapstructure:"extract"`
	Resilience       ResilienceConfig     `mapstructure:"resilience"`
	CircuitBreaker   CircuitBreakerConfig `mapstructure:"circuit_breaker"`
	CORS             CORSConfig           `mapstructure:"cors"`
	Captcha          CaptchaConfig        `mapstructure:"captcha"`
	Config2Capcha    Config2Captcha       `mapstructure:"2captcha"`
	GoogleConfig     GoogleConfig         `mapstructure:"google"`
	YandexConfig     EngineConfig         `mapstructure:"yandex"`
	BaiduConfig      EngineConfig         `mapstructure:"baidu"`
	BingConfig       EngineConfig         `mapstructure:"bing"`
	DuckDuckGoConfig EngineConfig         `mapstructure:"duckduckgo"`
	EcosiaConfig     EngineConfig         `mapstructure:"ecosia"`
}

type Config2Captcha added in v0.4.1

type Config2Captcha struct {
	ApiKey string `mapstructure:"apikey"`
}

type EngineConfig added in v0.6.0

type EngineConfig struct {
	core.SearchEngineOptions `mapstructure:",squash"`
	Proxy                    string `mapstructure:"proxy"`
	// Disabled leaves the engine out of serve: no endpoints, not used by mega.
	Disabled bool `mapstructure:"disabled"`
}

type GoogleConfig added in v0.8.14

type GoogleConfig struct {
	EngineConfig          `mapstructure:",squash"`
	core.URLResolveConfig `mapstructure:",squash"`
}

type ResilienceConfig added in v0.6.0

type ResilienceConfig struct {
	MaxRetries            int  `mapstructure:"max_retries"`
	AllowEndpointFallback bool `mapstructure:"allow_endpoint_fallback"`
}

type ServerConfig added in v0.6.0

type ServerConfig struct {
	Host          string `mapstructure:"host"`
	Port          int    `mapstructure:"port"`
	ConfigPath    string `mapstructure:"config_path"`
	IsDebug       bool   `mapstructure:"debug"`
	IsVerbose     bool   `mapstructure:"verbose"`
	IsQuiet       bool   `mapstructure:"quiet"`
	IsRawRequests bool   `mapstructure:"raw_requests"`
	Insecure      bool   `mapstructure:"insecure"`
}

Jump to

Keyboard shortcuts

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