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: colorizer (text colorization), grc (config file parsing)

§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");

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
grc
grc.rs - Configuration Parsing for Colorization Rules
utils
utils.rs - Utility functions for rgrc

Enums§

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

Constants§

EMBEDDED_CONFIGS
Embedded configuration files compiled into the binary when the embed-configs feature is enabled. Each entry is a tuple of (filename, contents) corresponding to files under share/conf.*. This file is generated by build.rs — do not edit.
EMBEDDED_CONFIG_NAMES
Names of the embedded config files (sorted)
EMBEDDED_GRC_CONF
The bundled rgrc.conf contents when embed-configs is enabled. This mirrors the on-disk etc/rgrc.conf file and is empty when embedding is disabled.
RESOURCE_PATHS
Standard resource paths searched for grcat config files.

Functions§

flush_and_rebuild_cache
Flush and rebuild the cache directory (embed-configs only)
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.