cli

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cli provides command-line interface utilities for the Lobster tool. It extracts configuration loading, authentication, display, and validation functions from the main package to improve testability and separation of concerns.

Index

Constants

View Source
const (
	// MinRate is the minimum allowed rate (requests per second).
	MinRate = 0.1
	// WarnRate is the warning threshold for low rates.
	WarnRate = 1.0
)

Variables

This section is empty.

Functions

func BuildAuthConfig

func BuildAuthConfig(opts *ConfigOptions) (*domain.AuthConfig, error)

BuildAuthConfig builds authentication configuration from environment variables and stdin. Credentials are read from: 1. Environment variables (LOBSTER_AUTH_PASSWORD, LOBSTER_AUTH_TOKEN, LOBSTER_AUTH_COOKIE) 2. Stdin when --auth-password-stdin or --auth-token-stdin flags are used CLI flags for credentials are intentionally not supported to prevent exposure in process lists.

func CenterText

func CenterText(text string, width int) string

CenterText centers text within a given width.

func IsInteractiveTerminal

func IsInteractiveTerminal() bool

IsInteractiveTerminal checks if the program is running in an interactive terminal.

func LoadConfiguration

func LoadConfiguration(configPath string, opts *ConfigOptions) (*domain.Config, error)

LoadConfiguration loads configuration from file (if provided) and merges with CLI options. CLI flags override file configuration values.

func PrintWarningBox

func PrintWarningBox(title string, lines []string)

PrintWarningBox prints a formatted warning box to stderr. The box has a consistent width and styling for security/ethical warnings.

func ReadSecretFromStdin

func ReadSecretFromStdin(name string) (string, error)

ReadSecretFromStdin reads a single line from stdin for secure credential input. Returns an error if stdin is empty or closed without data.

func ShowHelpMessage

func ShowHelpMessage(version string)

ShowHelpMessage prints the help message to stdout. The version parameter should be passed from the main package's version variable.

func ValidateRateLimit

func ValidateRateLimit(rate *float64) error

ValidateRateLimit enforces safe rate limiting to prevent accidental DoS. It modifies the rate pointer if the rate is below minimum.

Types

type ConfigOptions

type ConfigOptions struct {
	BaseURL            string
	Duration           string
	Timeout            string
	UserAgent          string
	OutputFile         string
	Rate               float64
	Concurrency        int
	MaxDepth           int
	QueueSize          int
	FollowLinks        bool
	Respect429         bool
	DryRun             bool
	Verbose            bool
	InsecureSkipVerify bool
	IgnoreRobots       bool
	AuthType           string
	AuthUsername       string
	AuthHeader         string
	AuthPasswordStdin  bool
	AuthTokenStdin     bool
}

ConfigOptions holds command-line flag values for configuration. These are passed to LoadConfiguration to build the final Config.

Jump to

Keyboard shortcuts

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