unilang_instruction_parser
A Rust crate for parsing CLI-like instruction strings into structured GenericInstruction objects, providing a configurable parser with detailed error reporting.
Features
- Command Paths: Supports single/multi-segment paths (e.g.,
cmd.sub,path/to/cmd). - Arguments: Parses positional and named arguments (
name::value). - Quoting & Escaping: Handles quoted values (
"val",'val') and standard escape sequences. - Help Operator: Recognizes
?for help requests. - Multiple Instructions: Parses
;;-separated instructions. - Error Reporting: Provides
ParseErrorwithErrorKindandSourceLocation. - Configurable: Customizes parsing rules via
UnilangParserOptions. no_stdSupport: Available via a feature flag.
Installation
Add unilang_instruction_parser as a dependency to your Cargo.toml:
[]
= { = "path/to/unilang_instruction_parser" } # Or version = "x.y.z" if published
(Adjust the path or version as necessary.)
Basic Usage
use ;
let options = default;
let parser = new;
let input = "log.level severity::\"debug\" message::'Hello, Unilang!' --verbose";
match parser.parse_single_str
Specification
This parser aims to strictly adhere to the (conceptual) unilang command language specification, which would typically be detailed in a document like unilang/spec.md.
License
This crate is licensed under the terms of the Apache License 2.0 or the MIT License, at your option.