How codad5/fli works
Project Type and Purpose
• FLI is an open-source Rust library for building CLI apps (in the style of commander.js).
• It exposes a procedural macro to bootstrap apps from Cargo.toml and a runtime API (Fli struct) for commands, options, and callbacks.
File Structure
Top level:
• .github/workflows: CI/CD (publish to crates.io)
• Dockerfile & docker-compose.yaml: containerize tests/sample
• Cargo.toml: crate metadata + dependencies
• sample/: example binary that uses FLI
• src/: library code
– lib.rs: public API entrypoint
– fli.rs: core engine (parser, dispatcher)
– macros.rs: proc-macro for init_fli_from_toml!
– tests.rs + tests/: unit tests
Extract Architectural Patterns
• Macro + Core-Library Pattern
• Modular design: parsing, command registration, option handling, callback execution
• CI/CD pipeline (GitHub Actions → crates.io)
• Example app illustrating integration
Main Components
A. User’s Application (sample/main.rs)
B. Procedural Macro (macros.rs)
C. FLI Core Engine (fli.rs)
1. Parser Module
2. Command & Option Builder
3. Callback Registry & Executor
4. Config Loader (reads Cargo.toml via the macro)
D. Public API Surface (lib.rs)
E. Tests (src/tests.rs + tests/)
F. CI/CD Pipeline (GitHub Actions workflow)
G. Containerization (Dockerfile, docker-compose)
Relationships & Data Flows
1. At compile time:
• sample app uses init_fli_from_toml! → macros.rs expands into initialization code
2. At runtime:
• User runs myapp [command] [options]
→ Parser Module reads std::env::args()
→ Matches against registered commands/options (Command & Option Builder data)
→ Populates values, checks required vs. optional
→ Dispatcher invokes user callbacks via Callback Registry
→ Outputs via stdout/stderr
3. Testing & CI:
• Unit tests import lib.rs → fli.rs → macros.rs
• GitHub Actions runs cargo test, cargo publish on tags
• Dockerfile & compose spin up a container for sample/demo
Technologies & Frameworks
• Rust (Cargo, crates.io)
• Procedural Macros
• GitHub Actions (publish.yml)
• Docker / docker-compose
Putting It All Together
Top row (Compile & CI):
[sample/main.rs] → (macro expansion) → [macros.rs]
[Cargo.toml] ──┐
↓
[lib.rs] ──→ [fli core modules]
Middle row (Runtime):
[User CLI Input] → [Parser] → [Command/Option Registry] → [Callback Executor] → [Stdout]
Bottom row (Infrastructure):
[GitHub Actions] → [crates.io publish]
[Dockerfile/docker-compose] → [Container for sample/test]