textcon/
lib.rs

1//! # textcon
2//!
3//! A template processing library and CLI tool for expanding file and directory references
4//! in text templates. Designed to prepare content for Large Language Models (LLMs) by
5//! embedding file contents and directory structures directly into templates.
6//!
7//! ## Features
8//!
9//! - Process templates containing `{{ @file.txt }}` references
10//! - Expand file contents inline
11//! - Generate directory tree representations
12//! - Security: prevents path traversal attacks
13//! - Flexible configuration options
14//!
15//! ## Usage
16//!
17//! ### As a Library
18//!
19//! ```no_run
20//! use textcon::{process_template, TemplateConfig};
21//!
22//! let template = "Here's my code:\n{{ @src/main.rs }}\n\nProject structure:\n{{ @. }}";
23//! let config = TemplateConfig::default();
24//!
25//! match textcon::process_template(template, &config) {
26//!     Ok(result) => println!("{}", result),
27//!     Err(e) => eprintln!("Error: {}", e),
28//! }
29//! ```
30//!
31//! ### As a CLI Tool
32//!
33//! ```bash
34//! # Process a template file
35//! textcon template.txt
36//!
37//! # Process template from stdin
38//! echo "Code: {{ @main.rs }}" | textcon
39//!
40//! # Process with custom base directory
41//! textcon template.txt -b /path/to/project
42//! ```
43
44pub mod error;
45pub mod fs_utils;
46pub mod template;
47
48// Re-export main types and functions for convenience
49pub use error::{Result, TextconError};
50pub use template::{
51    TemplateConfig, TemplateReference, find_references, process_reference, process_template,
52    process_template_file,
53};
54
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56pub const NAME: &str = env!("CARGO_PKG_NAME");