config

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

GoSQLX Configuration Package

This package provides configuration file support for the GoSQLX CLI, enabling persistent settings and team-wide consistency.

Overview

The configuration system allows users to define default settings for all CLI commands through YAML configuration files. This reduces the need for repetitive command-line flags and ensures consistent behavior across team members.

Features

  • Multiple configuration locations with precedence chain
  • CLI flag override - command-line flags always take priority
  • Schema validation - ensures configuration correctness
  • Partial configuration - only specify settings you want to change
  • Template generation - create configuration files with sensible defaults
  • Type safety - strongly-typed Go structs with validation

Configuration Locations

Configuration files are searched in the following order (highest priority first):

  1. Current directory: .gosqlx.yml
  2. Home directory: ~/.gosqlx.yml
  3. System-wide: /etc/gosqlx.yml
  4. Built-in defaults: Hardcoded sensible defaults

Configuration Schema

type Config struct {
    Format     FormatConfig     // SQL formatting options
    Validation ValidationConfig // SQL validation options
    Output     OutputConfig     // Output formatting options
    Analyze    AnalyzeConfig    // Analysis feature options
}
Format Configuration
type FormatConfig struct {
    Indent            int  // Indentation size (0-8 spaces)
    UppercaseKeywords bool // Convert keywords to uppercase
    MaxLineLength     int  // Maximum line length (0-500, 0=unlimited)
    Compact           bool // Use compact formatting
}
Validation Configuration
type ValidationConfig struct {
    Dialect    string // SQL dialect (postgresql, mysql, sqlserver, oracle, sqlite, generic)
    StrictMode bool   // Enable strict validation
    Recursive  bool   // Recursively process directories
    Pattern    string // File pattern for recursive processing
}
Output Configuration
type OutputConfig struct {
    Format  string // Output format (json, yaml, table, tree, auto)
    Verbose bool   // Enable verbose output
}
Analyze Configuration
type AnalyzeConfig struct {
    Security    bool // Enable security analysis
    Performance bool // Enable performance analysis
    Complexity  bool // Enable complexity analysis
    All         bool // Enable all analysis features
}

Usage

Loading Configuration
import "github.com/ajitpratap0/GoSQLX/cmd/gosqlx/internal/config"

// Load from default locations (with precedence)
cfg, err := config.LoadDefault()
if err != nil {
    // Handle error
}

// Load from specific file
cfg, err := config.Load("/path/to/config.yml")
if err != nil {
    // Handle error
}

// Create default configuration
cfg := config.DefaultConfig()
Saving Configuration
cfg := config.DefaultConfig()
cfg.Format.Indent = 4
cfg.Validation.Dialect = "mysql"

err := cfg.Save(".gosqlx.yml")
if err != nil {
    // Handle error
}
Validating Configuration
cfg, err := config.Load("config.yml")
if err != nil {
    // Handle error
}

// Validate configuration values
err = cfg.Validate()
if err != nil {
    // Configuration is invalid
    fmt.Printf("Invalid configuration: %v\n", err)
}
Merging Configurations
// Load base configuration
base := config.DefaultConfig()

// Create override configuration (e.g., from CLI flags)
override := &config.Config{
    Format: config.FormatConfig{
        Indent: 4,
    },
}

// Merge (override takes precedence)
base.Merge(override)

CLI Commands

Initialize Configuration
# Create .gosqlx.yml in current directory
gosqlx config init

# Create config in specific location
gosqlx config init --path ~/.gosqlx.yml
Validate Configuration
# Validate default config location
gosqlx config validate

# Validate specific file
gosqlx config validate --file /path/to/config.yml
Show Configuration
# Show current configuration as YAML
gosqlx config show

# Show as JSON
gosqlx config show --format json

# Show specific config file
gosqlx config show --file /path/to/config.yml

Example Configurations

Minimal Configuration
# Only specify what you want to change
format:
  indent: 4

validate:
  dialect: mysql
Team Configuration
# .gosqlx.yml - Project root configuration
format:
  indent: 2
  uppercase_keywords: true
  max_line_length: 100

validate:
  dialect: postgresql
  strict_mode: true
  recursive: false
  pattern: "*.sql"

output:
  format: table
  verbose: false

analyze:
  security: true
  performance: true
  complexity: true
  all: false
CI/CD Configuration
# Optimized for continuous integration
format:
  indent: 2
  uppercase_keywords: true
  max_line_length: 80
  compact: false

validate:
  dialect: postgresql
  strict_mode: true

output:
  format: json  # Machine-readable output
  verbose: false

analyze:
  all: true  # Comprehensive analysis
Personal Configuration
# ~/.gosqlx.yml - Personal preferences
format:
  indent: 4
  uppercase_keywords: false
  compact: true

output:
  verbose: true  # Always show details

Configuration Precedence

When multiple configuration sources exist, settings are merged with this precedence (highest to lowest):

  1. CLI flags - Explicit command-line arguments
  2. Current directory - .gosqlx.yml in working directory
  3. Home directory - ~/.gosqlx.yml in user's home
  4. System-wide - /etc/gosqlx.yml (Linux/macOS)
  5. Built-in defaults - Hardcoded in the application
Example

Given these configurations:

~/.gosqlx.yml (home):

format:
  indent: 4
  uppercase_keywords: true

.gosqlx.yml (current):

format:
  indent: 2

CLI command:

gosqlx format --uppercase=false query.sql

Effective configuration:

  • indent: 2 (from current directory)
  • uppercase_keywords: false (from CLI flag)
  • All other settings from defaults

Validation Rules

The package validates configuration values to ensure correctness:

  • indent: Must be between 0 and 8
  • max_line_length: Must be between 0 and 500
  • dialect: Must be one of: postgresql, mysql, sqlserver, oracle, sqlite, generic
  • output.format: Must be one of: json, yaml, table, tree, auto

Testing

The package includes comprehensive tests:

# Run all config tests
go test ./cmd/gosqlx/internal/config/

# Run with coverage
go test -cover ./cmd/gosqlx/internal/config/

# Run specific test
go test -run TestLoadDefault ./cmd/gosqlx/internal/config/

Schema Validation

The schema.go file defines the complete configuration schema with validation functions:

import "github.com/ajitpratap0/GoSQLX/cmd/gosqlx/internal/config"

// Validate individual settings
err := config.ValidateDialect("mysql")
err = config.ValidateIndent(4)
err = config.ValidateOutputFormat("json")
err = config.ValidateMaxLineLength(100)

// Get schema information
schema := config.GetSchema()
fmt.Printf("Valid dialects: %v\n", schema.Validation.Dialect.Options)

Integration with CLI Commands

All CLI commands automatically integrate with the configuration system:

// In a CLI command handler
func commandRun(cmd *cobra.Command, args []string) error {
    // Load configuration
    cfg, err := config.LoadDefault()
    if err != nil {
        cfg = config.DefaultConfig()
    }

    // Override with CLI flags if explicitly set
    if cmd.Flags().Changed("indent") {
        cfg.Format.Indent = indentFlag
    }

    // Use configuration
    formatter := NewFormatter(cfg.Format)
    // ...
}

Best Practices

  1. Project configuration: Place .gosqlx.yml in project root for team consistency
  2. Personal overrides: Use ~/.gosqlx.yml for personal preferences
  3. CI/CD: Use explicit CLI flags in CI pipelines for clarity
  4. Validation: Always run gosqlx config validate after editing config files
  5. Documentation: Comment your config files to explain choices
  6. Version control: Commit .gosqlx.yml to git for team sharing
  7. Minimal config: Only specify settings that differ from defaults

Error Handling

The package provides clear error messages for common issues:

// File not found - falls back to defaults
cfg, err := config.Load("nonexistent.yml")
// err: "failed to read config file: no such file or directory"

// Invalid YAML syntax
cfg, err := config.Load("malformed.yml")
// err: "failed to parse config file: yaml: ..."

// Invalid values
err := cfg.Validate()
// err: "format.indent must be between 0 and 8, got 15"

// Invalid dialect
cfg.Validation.Dialect = "unknown"
err = cfg.Validate()
// err: "validate.dialect must be one of: [postgresql mysql ...], got 'unknown'"

Template File

The package includes a template configuration file (template.yml) with:

  • Comprehensive comments
  • All available options
  • Sensible defaults
  • Usage examples

This template is automatically used by gosqlx config init.

Performance

The configuration system is designed for efficiency:

  • Fast loading: YAML parsing is optimized
  • Cached defaults: Default config is reused
  • Minimal overhead: Configuration loading adds <1ms to startup
  • No hot reloading: Config is loaded once per command execution

Thread Safety

All configuration operations are thread-safe:

  • Read operations can be performed concurrently
  • Each command gets its own config instance
  • No shared mutable state

Future Enhancements

Planned improvements for future releases:

  • Environment variable overrides
  • Configuration validation on file change
  • IDE integration for config autocomplete
  • Configuration profiles (dev, staging, prod)
  • Remote configuration support

Contributing

When adding new configuration options:

  1. Update the struct types in config.go
  2. Add validation in Validate() method
  3. Update schema in schema.go
  4. Add tests in config_test.go
  5. Update template in template.yml
  6. Update documentation

License

This package is part of GoSQLX and is licensed under the Apache License 2.0.

Documentation

Overview

Package config provides configuration file management for the gosqlx CLI.

Overview

This package handles loading, parsing, validating, and saving configuration files for the gosqlx CLI. Configuration files allow users to set default values for command options, reducing the need for repetitive command-line flags.

Configuration File Format

GoSQLX uses YAML format for configuration files (.gosqlx.yml):

format:
  indent: 2
  uppercase_keywords: true
  max_line_length: 80
  compact: false

validate:
  dialect: postgresql
  strict_mode: false
  recursive: false
  pattern: "*.sql"
  security:
    max_file_size: 10485760  # 10MB

output:
  format: auto
  verbose: false

analyze:
  security: true
  performance: true
  complexity: true
  all: false

Configuration Search Path

Configuration files are searched in the following order with precedence:

  1. Current directory: .gosqlx.yml
  2. Home directory: ~/.gosqlx.yml
  3. System-wide: /etc/gosqlx.yml
  4. Built-in defaults (if no config file found)

CLI flags always override configuration file settings.

Usage

## Loading Configuration

Load from default locations:

cfg, err := config.LoadDefault()
if err != nil {
    // Handle error or use defaults
    cfg = config.DefaultConfig()
}

Load from specific file:

cfg, err := config.Load("/path/to/config.yml")
if err != nil {
    return err
}

## Creating Configuration

Create with defaults:

cfg := config.DefaultConfig()

Customize settings:

cfg.Format.Indent = 4
cfg.Format.UppercaseKeywords = false
cfg.Validation.Dialect = "mysql"

## Saving Configuration

Save to file:

if err := cfg.Save(".gosqlx.yml"); err != nil {
    return err
}

## Validation

Configuration is automatically validated during Load():

cfg, err := config.Load("config.yml")
// cfg is validated, or err contains validation errors

Explicit validation:

if err := cfg.Validate(); err != nil {
    // Handle validation errors
}

## Merging Configurations

Merge CLI flags with config file (CLI flags take precedence):

cfg, _ := config.LoadDefault()
cliConfig := &config.Config{
    Format: config.FormatConfig{Indent: 4}, // From CLI flag
}
cfg.Merge(cliConfig)

Configuration Sections

## Format Configuration

Controls SQL formatting behavior:

format:
  indent: 2                    # Indentation size in spaces (0-8)
  uppercase_keywords: true     # Uppercase SQL keywords
  max_line_length: 80          # Maximum line length (0-500)
  compact: false               # Compact format (minimal whitespace)

Fields:

  • Indent: Number of spaces for indentation (default: 2)
  • UppercaseKeywords: Convert keywords to uppercase (default: true)
  • MaxLineLength: Maximum line length for wrapping (default: 80)
  • Compact: Use compact format with minimal whitespace (default: false)

## Validation Configuration

Controls SQL validation behavior:

validate:
  dialect: postgresql          # SQL dialect for validation
  strict_mode: false           # Enable strict validation
  recursive: false             # Recursively process directories
  pattern: "*.sql"             # File pattern for recursive processing
  security:
    max_file_size: 10485760    # Maximum file size in bytes

Fields:

  • Dialect: SQL dialect (postgresql, mysql, sqlserver, oracle, sqlite, generic)
  • StrictMode: Enable strict validation rules (default: false)
  • Recursive: Recursively process directories (default: false)
  • Pattern: File pattern for recursive processing (default: "*.sql")
  • Security.MaxFileSize: Maximum allowed file size in bytes (default: 10MB)

## Output Configuration

Controls output formatting and verbosity:

output:
  format: auto                 # Output format (json, yaml, table, tree, auto)
  verbose: false               # Enable verbose output

Fields:

  • Format: Output format (json, yaml, table, tree, auto) (default: auto)
  • Verbose: Enable detailed output for debugging (default: false)

## Analysis Configuration

Controls SQL analysis behavior:

analyze:
  security: true               # Perform security analysis
  performance: true            # Perform performance analysis
  complexity: true             # Calculate complexity metrics
  all: false                   # Comprehensive analysis (all above)

Fields:

  • Security: Enable security vulnerability detection (default: true)
  • Performance: Enable performance analysis (default: true)
  • Complexity: Enable complexity metrics (default: true)
  • All: Enable comprehensive analysis (default: false)

Configuration Validation

The package validates configuration values to ensure they are within acceptable ranges:

Format validation:

  • Indent: 0-8 spaces
  • MaxLineLength: 0-500 characters

Validation validation:

  • Dialect: Must be one of: postgresql, mysql, sqlserver, oracle, sqlite, generic

Output validation:

  • Format: Must be one of: json, yaml, table, tree, auto

Invalid configurations are rejected with descriptive error messages.

CLI Flag Precedence

Configuration files provide defaults, but CLI flags always take precedence:

# Config file has indent: 2
gosqlx format query.sql               # Uses indent: 2 from config
gosqlx format --indent 4 query.sql    # Uses indent: 4 from CLI flag

The package tracks which flags were explicitly set to ensure proper precedence.

Schema Validation

The package provides schema validation utilities in schema.go:

  • Schema definition for configuration structure
  • Type checking for configuration values
  • Range validation for numeric values
  • Enum validation for string values

Schema validation is used by:

  • Load() function to validate loaded configurations
  • Validate() method to check configuration correctness
  • CLI config validate command to verify user configurations

Error Handling

Configuration errors are returned with context:

cfg, err := config.Load("config.yml")
if err != nil {
    // Possible errors:
    // - File not found
    // - YAML parsing error
    // - Validation error
    // - Home directory lookup failure
}

Validation errors include field names and acceptable ranges:

invalid configuration: format.indent must be between 0 and 8, got 10
invalid configuration: validate.dialect must be one of: [postgresql mysql ...], got 'custom'

Best Practices

## Project Configuration

Place .gosqlx.yml in project root for team-wide defaults:

# .gosqlx.yml
format:
  indent: 2
  uppercase_keywords: true

validate:
  dialect: postgresql
  recursive: true

## User Configuration

Place .gosqlx.yml in home directory for personal defaults:

# ~/.gosqlx.yml
output:
  verbose: true

format:
  indent: 4

## CI/CD Configuration

Use explicit flags in CI/CD for clarity and reproducibility:

gosqlx validate --dialect postgresql --strict ./sql/
gosqlx format --check --indent 2 ./sql/*.sql

Thread Safety

Configuration objects are not thread-safe. Each goroutine should have its own configuration instance or use appropriate synchronization.

Loading configuration is safe for concurrent use as it creates new instances.

Performance

Configuration loading is optimized:

  • Files are loaded once and cached by the application
  • YAML parsing uses efficient unmarshalers
  • Validation is performed once at load time

Configuration file size should be kept small (< 1KB typically) for fast loading.

Examples

## Complete Configuration Example

# .gosqlx.yml - Complete configuration example
format:
  indent: 2
  uppercase_keywords: true
  max_line_length: 80
  compact: false

validate:
  dialect: postgresql
  strict_mode: false
  recursive: true
  pattern: "*.sql"
  security:
    max_file_size: 10485760

output:
  format: auto
  verbose: false

analyze:
  security: true
  performance: true
  complexity: true
  all: false

## Programmatic Configuration

// Create custom configuration
cfg := &config.Config{
    Format: config.FormatConfig{
        Indent:            4,
        UppercaseKeywords: false,
        MaxLineLength:     120,
        Compact:           false,
    },
    Validation: config.ValidationConfig{
        Dialect:    "mysql",
        StrictMode: true,
        Recursive:  true,
        Pattern:    "*.sql",
        Security: config.SecurityConfig{
            MaxFileSize: 5 * 1024 * 1024, // 5MB
        },
    },
    Output: config.OutputConfig{
        Format:  "json",
        Verbose: true,
    },
    Analyze: config.AnalyzeConfig{
        Security:    true,
        Performance: true,
        Complexity:  true,
        All:         false,
    },
}

// Validate
if err := cfg.Validate(); err != nil {
    log.Fatal(err)
}

// Save to file
if err := cfg.Save(".gosqlx.yml"); err != nil {
    log.Fatal(err)
}

See Also

  • cmd/gosqlx/cmd/config.go - Config management commands
  • cmd/gosqlx/cmd/config_manager.go - Config manager implementation
  • docs/CONFIGURATION.md - User-facing configuration documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidDialects = []string{
	"postgresql",
	"mysql",
	"sqlserver",
	"oracle",
	"sqlite",
	"generic",
}

ValidDialects lists all supported SQL dialects

View Source
var ValidOutputFormats = []string{
	"json",
	"yaml",
	"table",
	"tree",
	"auto",
}

ValidOutputFormats lists all supported output formats

Functions

func ValidateDialect

func ValidateDialect(dialect string) error

ValidateDialect checks if a dialect is valid

func ValidateIndent

func ValidateIndent(indent int) error

ValidateIndent checks if indent value is within acceptable range

func ValidateMaxLineLength

func ValidateMaxLineLength(length int) error

ValidateMaxLineLength checks if max line length is within acceptable range

func ValidateOutputFormat

func ValidateOutputFormat(format string) error

ValidateOutputFormat checks if an output format is valid

Types

type AnalyzeConfig

type AnalyzeConfig struct {
	Security    bool `yaml:"security"`
	Performance bool `yaml:"performance"`
	Complexity  bool `yaml:"complexity"`
	All         bool `yaml:"all"`
}

AnalyzeConfig holds SQL analysis options.

Controls which analysis features are enabled by default.

Fields:

  • Security: Perform security vulnerability analysis (default: true)
  • Performance: Perform performance analysis (default: true)
  • Complexity: Calculate complexity metrics (default: true)
  • All: Enable comprehensive analysis (default: false)

type AnalyzeSchema

type AnalyzeSchema struct {
	Security struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"security"`
	Performance struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"performance"`
	Complexity struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"complexity"`
	All struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"all"`
}

AnalyzeSchema defines constraints for analyze settings

type Config

type Config struct {
	Format     FormatConfig     `yaml:"format"`
	Validation ValidationConfig `yaml:"validate"`
	Output     OutputConfig     `yaml:"output"`
	Analyze    AnalyzeConfig    `yaml:"analyze"`
}

Config represents the complete GoSQLX CLI configuration.

Configuration files use YAML format and are loaded from:

  1. Current directory: .gosqlx.yml
  2. Home directory: ~/.gosqlx.yml
  3. System: /etc/gosqlx.yml

CLI flags always override configuration file settings.

Example configuration file:

format:
  indent: 2
  uppercase_keywords: true
  max_line_length: 80
  compact: false

validate:
  dialect: postgresql
  strict_mode: false
  recursive: false
  pattern: "*.sql"
  security:
    max_file_size: 10485760

output:
  format: auto
  verbose: false

analyze:
  security: true
  performance: true
  complexity: true
  all: false

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a configuration with sensible defaults.

This function creates a Config instance with production-ready defaults suitable for most use cases. These defaults balance performance, code quality, and compatibility.

Default values:

  • Format: 2-space indentation, uppercase keywords, 80-char line length
  • Validation: PostgreSQL dialect, non-strict mode, *.sql pattern
  • Security: 10MB max file size
  • Output: Auto format selection, non-verbose
  • Analysis: All features enabled except comprehensive mode

Returns:

  • *Config with default values initialized

Usage:

cfg := config.DefaultConfig()
cfg.Format.Indent = 4  // Customize as needed
cfg.Save(".gosqlx.yml")

func Load

func Load(path string) (*Config, error)

Load reads a configuration file from the specified path.

This function loads and parses a YAML configuration file, validates the configuration values, and returns a Config instance.

The path is automatically expanded if it starts with ~ (home directory).

Parameters:

  • path: File path to the configuration file (absolute or relative)

Returns:

  • *Config: Loaded and validated configuration
  • error: File reading, parsing, or validation error

Possible errors:

  • File not found or inaccessible
  • Invalid YAML syntax
  • Configuration validation failure (invalid values)
  • Home directory lookup failure (for ~ expansion)

Example:

cfg, err := config.Load(".gosqlx.yml")
if err != nil {
    log.Fatalf("Failed to load config: %v", err)
}
fmt.Printf("Using dialect: %s\n", cfg.Validation.Dialect)

func LoadDefault

func LoadDefault() (*Config, error)

LoadDefault tries to load configuration from standard locations with precedence.

This function searches for configuration files in multiple standard locations and loads the first one found. If no configuration file exists, it returns a default configuration.

Search order (first found wins):

  1. Current directory: .gosqlx.yml
  2. Home directory: ~/.gosqlx.yml
  3. System-wide: /etc/gosqlx.yml
  4. Built-in defaults (if no file found)

This allows for flexible configuration strategies:

  • Project-specific config in current directory
  • User-specific config in home directory
  • System-wide config for all users
  • Automatic fallback to sensible defaults

Returns:

  • *Config: Loaded configuration or defaults
  • error: Always returns a valid Config (errors are logged but not fatal)

Example:

cfg, err := config.LoadDefault()
// cfg is always non-nil, even if err != nil
// err indicates which config was loaded or if defaults were used

func (*Config) Merge

func (c *Config) Merge(other *Config)

Merge applies settings from another config, with the other config taking precedence

func (*Config) Save

func (c *Config) Save(path string) error

Save writes the configuration to the specified path

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type ConfigSchema

type ConfigSchema struct {
	Format     FormatSchema     `yaml:"format"`
	Validation ValidationSchema `yaml:"validate"`
	Output     OutputSchema     `yaml:"output"`
	Analyze    AnalyzeSchema    `yaml:"analyze"`
}

ConfigSchema defines the structure and constraints for configuration

func GetSchema

func GetSchema() *ConfigSchema

GetSchema returns the complete configuration schema with descriptions

type FormatConfig

type FormatConfig struct {
	Indent            int  `yaml:"indent"`
	UppercaseKeywords bool `yaml:"uppercase_keywords"`
	MaxLineLength     int  `yaml:"max_line_length"`
	Compact           bool `yaml:"compact"`
}

FormatConfig holds SQL formatting options.

Controls how SQL is formatted by the format command.

Fields:

  • Indent: Number of spaces for indentation (0-8, default: 2)
  • UppercaseKeywords: Convert SQL keywords to uppercase (default: true)
  • MaxLineLength: Maximum line length for wrapping (0-500, default: 80)
  • Compact: Use compact format with minimal whitespace (default: false)

type FormatSchema

type FormatSchema struct {
	Indent struct {
		Min     int    `yaml:"min"`
		Max     int    `yaml:"max"`
		Default int    `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"indent"`
	UppercaseKeywords struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"uppercase_keywords"`
	MaxLineLength struct {
		Min     int    `yaml:"min"`
		Max     int    `yaml:"max"`
		Default int    `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"max_line_length"`
	Compact struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"compact"`
}

FormatSchema defines constraints for format settings

type OutputConfig

type OutputConfig struct {
	Format  string `yaml:"format"` // json, yaml, table
	Verbose bool   `yaml:"verbose"`
}

OutputConfig holds output formatting options.

Controls output format and verbosity for all commands.

Fields:

  • Format: Output format (json, yaml, table, tree, auto) (default: auto)
  • Verbose: Enable detailed output for debugging (default: false)

type OutputSchema

type OutputSchema struct {
	Format struct {
		Options []string `yaml:"options"`
		Default string   `yaml:"default"`
		Desc    string   `yaml:"description"`
	} `yaml:"format"`
	Verbose struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"verbose"`
}

OutputSchema defines constraints for output settings

type SecurityConfig

type SecurityConfig struct {
	MaxFileSize int64 `yaml:"max_file_size"` // Maximum file size in bytes
}

SecurityConfig holds security-related limits for file operations.

Prevents resource exhaustion and security vulnerabilities.

Fields:

  • MaxFileSize: Maximum allowed file size in bytes (default: 10MB)

Example:

security:
  max_file_size: 20971520  # 20MB

type ValidationConfig

type ValidationConfig struct {
	Dialect    string         `yaml:"dialect"`
	StrictMode bool           `yaml:"strict_mode"`
	Recursive  bool           `yaml:"recursive"`
	Pattern    string         `yaml:"pattern"`
	Security   SecurityConfig `yaml:"security"`
}

ValidationConfig holds SQL validation options.

Controls validation behavior including dialect selection and security limits.

Fields:

  • Dialect: SQL dialect for validation (postgresql, mysql, sqlserver, oracle, sqlite, generic)
  • StrictMode: Enable strict validation rules (default: false)
  • Recursive: Recursively process directories (default: false)
  • Pattern: File pattern for recursive processing (default: "*.sql")
  • Security: Security-related limits (file size, etc.)

type ValidationSchema

type ValidationSchema struct {
	Dialect struct {
		Options []string `yaml:"options"`
		Default string   `yaml:"default"`
		Desc    string   `yaml:"description"`
	} `yaml:"dialect"`
	StrictMode struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"strict_mode"`
	Recursive struct {
		Default bool   `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"recursive"`
	Pattern struct {
		Default string `yaml:"default"`
		Desc    string `yaml:"description"`
	} `yaml:"pattern"`
}

ValidationSchema defines constraints for validation settings

Jump to

Keyboard shortcuts

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