Skip to main content

bare_script/
lib.rs

1//! bare-script: The type-safe scripting authority for Rust.
2//!
3//! A framework for building robust shell commands and automation
4//! with "Parse, don't validate" philosophy.
5//!
6//! # Overview
7//!
8//! This library provides two APIs:
9//! - **Sync API** (`sync::CommandBuilder`): Uses `std::process::Command`
10//! - **Async API** (`proc::CommandBuilder`): Uses `tokio::process::Command`
11//!
12//! # Quick Start - Sync
13//!
14//! ```rust
15//! use bare_script::sync::CommandBuilder;
16//!
17//! #[cfg(not(windows))]
18//! {
19//! let output = CommandBuilder::new("echo")
20//!     .arg("Hello, world!")
21//!     .capture_output()
22//!     .execute();
23//!
24//! assert!(output.is_ok());
25//! assert!(output.unwrap().success());
26//! }
27//! ```
28//!
29//! # Quick Start - Async
30//!
31//! ```rust
32//! use bare_script::proc::CommandBuilder;
33//!
34//! #[tokio::main]
35//! async fn main() -> Result<(), bare_script::ScriptError> {
36//!     #[cfg(not(windows))]
37//!     {
38//!     let output = CommandBuilder::new("echo")
39//!         .arg("Hello, world!")
40//!         .capture_output()
41//!         .execute()
42//!         .await;
43//!
44//!     assert!(output.is_ok());
45//!     assert!(output.unwrap().success());
46//!     }
47//!     Ok(())
48//! }
49//! ```
50
51#![warn(missing_docs)]
52
53pub mod args;
54pub mod config;
55pub mod error;
56pub mod logging;
57pub mod output;
58pub mod proc;
59pub mod shell;
60pub mod sync;
61
62pub use args::{Arg, ArgType, Args};
63pub use config::{Config, StdioConfig};
64pub use error::{ScriptError, ScriptResult};
65pub use output::Output;
66
67#[cfg(feature = "tokio-rt")]
68pub use proc::CommandBuilder as AsyncCommandBuilder;
69
70#[cfg(not(feature = "tokio-rt"))]
71#[deprecated(since = "0.1.0", note = "Enable tokio-rt feature to use async API")]
72pub type AsyncCommandBuilder = sync::CommandBuilder;
73
74pub use sync::CommandBuilder;
75pub use sync::Pipeline;
76
77#[cfg(feature = "tokio-rt")]
78pub use proc::Pipeline as AsyncPipeline;