Skip to main content

Crate rgrc

Crate rgrc 

Source
Expand description

Core library: config loading, colorization, and regex engine selection.

Re-exports§

pub use style::Style;

Modules§

args
CLI argument parsing.
buffer
Line-buffered writer: flushes after each newline for real-time output.
colorizer
Apply regex-based color rules to input text line by line.
enhanced_regex
Lightweight lookahead/lookbehind support on top of regex_lite.
grc
Parse grc.conf (command to config mapping) and grcat config files (regex + style rules). Uses a hybrid regex engine: standard regex_lite for simple patterns, fancy-regex or EnhancedRegex for lookarounds.
style
Zero-dependency ANSI styling: 8 colors, bright variants, text attributes.
utils
utils.rs - Utility functions for rgrc

Enums§

ColorMode
On = always color, Off = never, Auto = only when stdout is a TTY.

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

Functions§

load_config
Load rules for pseudo_command by matching it against the patterns in the mapper file at path, then reading the referenced conf file from the first matching resource path. Embedded configs are the last resort so that user files on disk always win. Returns empty vec on any failure.
load_grcat_config
Load and parse a grcat conf file. Returns empty vec on any error (file not found, parse failure). Falls back to embedded cache when the embed-configs feature is enabled.
load_rules_for_command
Load colorization rules for a given pseudo-command by searching all configuration paths. The search stops at the first mapper file that yields rules. Priority: user mapper ($XDG_CONFIG_HOME/rgrc/rgrc.conf), then the remaining mapper paths ending with legacy grc locations; the embedded mapper is the last resort.
load_rules_for_config
Rules for an explicitly requested config (-c NAME): NAME is first tried as a pseudo-command against the mappers, then directly as a conf file name (“df” resolves to conf.df; “conf.df” and paths are used as-is).
resource_paths
Search paths for conf files, user config first, system/legacy last. Honors the XDG base directory environment variables; grc paths are kept for compatibility. The development share/ dir requires RGRC_DEV_SHARE.