comlexr
comlexr is a Rust procedural macro crate designed to simplify command expression generation by using flexible syntax constructs. It allows you to dynamically build command-line instructions based on conditional statements, loops, pattern matching, closures, and more.
Installation
Add comlexr to your project's Cargo.toml:
[]
= "1.0.0"
Rust Edition
This project uses Rust 2018 edition to ensure compatibility and stable language features.
Usage
Basic Command Construction
Create simple command expressions using the cmd! macro.
use cmd;
let command = cmd!;
assert_eq!;
Conditional Argument Inclusion
Use if statements to conditionally include arguments.
use cmd;
let single = true;
let multi = false;
let command = cmd!;
assert_eq!;
Conditional Pattern Matching
Use if let syntax to conditionally include arguments based on pattern matching.
use cmd;
let single_option = Some;
let multi_option: = None;
let command = cmd!;
assert_eq!;
Iterative Argument Inclusion
Use the for syntax to iterate over collections and include multiple arguments.
use cmd;
let iter = &;
let command = cmd!;
assert_eq!;
Iteration with for in
Leverage the for in syntax to map collection elements to arguments dynamically.
use cmd;
let single_iter = &;
let multi_iter = &;
let command = cmd!;
assert_eq!;
Pattern Matching with match
Dynamically choose arguments based on pattern matching.
use cmd;
let match_arg = Arg2;
let command = cmd!;
assert_eq!;
Closures for Dynamic Argument Generation
Generate arguments on the fly using closures. The closure must return a type that implements IntoIterator.
use cmd;
let arr = vec!;
let input = 2;
let command = cmd!;
assert_eq!;
Features
- Conditional expressions (
if,if let) - Iteration constructs (
for,for in) - Pattern matching (
match) - Support for closures and dynamic expressions
Examples
See the tests directory for more examples on how to use comlexr effectively in your project.
License
This project is licensed under the MIT License.