Skip to main content

toargv_template/
lib.rs

1//! Argument templates for [`toargv`](https://crates.io/crates/toargv).
2//!
3//! The crate parses an ordered argv template and expands paths from a
4//! [`serde_json::Value`] configuration tree into command-line arguments.
5//!
6//! ```
7//! use serde_json::json;
8//! use toargv_template::{Template, expand};
9//!
10//! let template = Template::parse(&[
11//!     "--output".to_owned(),
12//!     "{output}".to_owned(),
13//!     "{input}".to_owned(),
14//! ])?;
15//! let arguments = expand(
16//!     &json!({"output": "result.txt", "input": "source.txt"}),
17//!     &template,
18//! )?;
19//!
20//! assert_eq!(arguments, ["--output", "result.txt", "source.txt"]);
21//! # Ok::<(), Box<dyn std::error::Error>>(())
22//! ```
23#![warn(missing_docs)]
24
25/// Errors returned by template parsing and expansion.
26pub mod error;
27/// Argument expansion from configuration values.
28pub mod expand;
29/// Paths into JSON-compatible configuration trees.
30pub mod path;
31/// The validated argv template model and parser.
32pub mod template;
33
34pub use error::Error;
35pub use expand::expand;
36pub use path::ConfigPath;
37pub use template::Template;