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
- func BuildAuthConfig(opts *ConfigOptions) (*domain.AuthConfig, error)
- func CenterText(text string, width int) string
- func IsInteractiveTerminal() bool
- func LoadConfiguration(configPath string, opts *ConfigOptions) (*domain.Config, error)
- func PrintWarningBox(title string, lines []string)
- func ReadSecretFromStdin(name string) (string, error)
- func ShowHelpMessage(version string)
- func ValidateRateLimit(rate *float64) error
- type ConfigOptions
Constants ¶
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 ¶
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 ¶
PrintWarningBox prints a formatted warning box to stderr. The box has a consistent width and styling for security/ethical warnings.
func ReadSecretFromStdin ¶
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 ¶
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.