1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//! Macros for ergonomic command execution
//!
//! This module provides command execution macros that offer a similar experience
//! to JavaScript's `$` tagged template literal for shell command execution.
//!
//! ## Available Macros
//!
//! - `s!` - Short, concise macro (recommended for most use cases)
//! - `sh!` - Shell macro (alternative short form)
//! - `cmd!` - Command macro (explicit name)
//! - `cs!` - Command-stream macro (another alternative)
//!
//! All macros are aliases and provide identical functionality.
//!
//! ## Usage
//!
//! ```rust,no_run
//! use command_stream::s;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Simple command
//! let result = s!("echo hello world").await?;
//!
//! // With interpolation (values are automatically quoted for safety)
//! let name = "John Doe";
//! let result = s!("echo Hello, {}", name).await?;
//!
//! // Multiple arguments
//! let file = "test.txt";
//! let dir = "/tmp";
//! let result = s!("cp {} {}", file, dir).await?;
//!
//! Ok(())
//! }
//! ```
/// Build a shell command with interpolated values safely quoted
///
/// This function is used internally by the `cmd!` macro to build
/// shell commands with properly quoted interpolated values.
/// Helper function to create a ProcessRunner from a command string
/// Helper function to create a ProcessRunner with custom options
/// The `cmd!` macro for ergonomic shell command execution
///
/// This macro provides a similar experience to JavaScript's `$` tagged template literal.
/// Values interpolated into the command are automatically quoted for shell safety.
///
/// Note: Consider using the shorter `s!` or `sh!` aliases for more concise code.
///
/// # Examples
///
/// ```rust,no_run
/// use command_stream::s;
///
/// # async fn example() -> Result<(), command_stream::Error> {
/// // Simple command (returns a future that can be awaited)
/// let result = s!("echo hello").await?;
///
/// // With string interpolation
/// let name = "world";
/// let result = s!("echo hello {}", name).await?;
///
/// // With multiple values
/// let src = "source.txt";
/// let dst = "dest.txt";
/// let result = s!("cp {} {}", src, dst).await?;
///
/// // Values with special characters are automatically quoted
/// let filename = "file with spaces.txt";
/// let result = s!("cat {}", filename).await?; // Safely handles spaces
/// # Ok(())
/// # }
/// ```
///
/// # Safety
///
/// All interpolated values are automatically quoted using shell-safe quoting,
/// preventing command injection attacks.
/// The `sh!` macro - alias for `cmd!`
///
/// This is an alternative name for `cmd!` that some users may find
/// more intuitive for shell command execution.
/// The `s!` macro - short alias for `cmd!`
///
/// This is a concise alternative to `cmd!` for quick shell command execution.
/// Recommended for use in documentation and examples.
/// The `cs!` macro - alias for `cmd!`
///
/// Short for "command-stream", this provides another alternative
/// for shell command execution.