Skip to main content

Crate rgrc

Crate rgrc 

Source
Expand description

§lib.rs - Core Library for rgrc

This module provides the core functionality of rgrc (Rust GRC), a colorization tool that applies syntax highlighting to command output based on configuration rules.

§Architecture

The library is organized into the following components:

  • ColorMode: Controls whether color output is enabled (On/Off/Auto)
  • Configuration Loading: Functions to load colorization rules from config files
  • Submodules:
    • style: Lightweight ANSI styling (replaces console crate)
    • colorizer: Text colorization engine
    • grc: Config file parsing with hybrid regex engine
    • enhanced_regex: Custom lookaround implementation (used when fancy feature is disabled)

§Features

  • embed-configs (default): Embed configuration files into binary
  • fancy-regex (default): Use battle-tested fancy-regex for enhanced patterns
    • Disable for smaller binary: cargo build --no-default-features --features=embed-configs
  • timetrace: Enable timing trace for performance profiling

§Regex Engine

rgrc uses a hybrid regex approach:

  • Simple patterns → Standard regex crate (fast)
  • Complex patterns → fancy-regex (default) or EnhancedRegex (lightweight)

See grc::CompiledRegex documentation for details.

§Usage Example

use rgrc::{ColorMode, load_config, load_grcat_config};

// Determine if colors should be used
let color_mode = ColorMode::Auto;

// Load colorization rules for a specific command
let rules = load_config("~/.config/rgrc/grc.conf", "ping");

Re-exports§

pub use style::Style;

Modules§

args
args.rs - Command-line argument parsing for rgrc
buffer
buffer.rs - Buffered writers for rgrc
colorizer
colorizer.rs - Text Colorization Engine for rgrc
enhanced_regex
Enhanced Regex Implementation - Lightweight Lookaround Support
grc
grc.rs - Configuration Parsing for Colorization Rules
style
Lightweight ANSI style implementation
utils
utils.rs - Utility functions for rgrc

Enums§

ColorMode
Control whether colored output should be enabled for this run.

Constants§

RESOURCE_PATHS
Standard resource paths searched for grcat config files.

Functions§

load_config
Load colorization rules for a given command from a grc.conf-style configuration file.
load_grcat_config
Load colorization rules from a grcat.conf-style configuration file.
load_rules_for_command
Load colorization rules for a given pseudo-command by searching all configuration paths.