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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// Copyright © 2023 xtasks. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! # Macros
//!
//! This module provides convenient macros for common operations in the library.
/// Prints a formatted message to the console with a newline.
///
/// # Parameters
///
/// * `args`: The format string and values to print.
///
/// # Examples
///
/// ```rust
/// println!("This is a {} message", "formatted");
/// ```
/// Prints a formatted message to the console without a newline.
///
/// # Parameters
///
/// * `args`: The format string and values to print.
///
/// # Examples
///
/// ```rust
/// print!("This is a {} message", "formatted");
/// ```
/// Macros related to asserting conditions in the code.
///
/// Asserts that a condition is true, and panics with a formatted message if it is not.
///
/// # Parameters
///
/// * `$cond`: The condition to assert.
/// * `args`: The format string and values for the panic message if the assertion fails.
///
/// # Examples
///
/// ```rust
/// assert!(1 + 1 == 2, "Math is broken!");
/// ```
/// Macros related to executing shell commands.
///
/// Executes a shell command, logs the start and completion of the operation, and handles any errors that occur.
///
/// # Parameters
///
/// * `$command`: The shell command to execute.
/// * `$package`: The name of the package the command is being run on.
/// * `$operation`: A description of the operation being performed.
/// * `$start_message`: The log message to be displayed at the start of the operation.
/// * `$complete_message`: The log message to be displayed upon successful completion of the operation.
/// * `$error_message`: The log message to be displayed in case of an error.
///
/// # Returns
///
/// Returns a `Result<(), anyhow::Error>` indicating the success or failure of the operation.
///
/// Executes a cargo command with optional arguments and error handling.
///
/// This macro simplifies the execution of cargo commands, handling optional arguments based on the CI configuration,
/// and providing a context for any errors that occur.
///
/// # Parameters
///
/// * `command`: The base cargo command to execute (e.g., "fmt", "clippy", "test").
/// * `nightly`: A boolean indicating whether to run the command with the nightly compiler.
/// * `args`: Additional arguments to pass to the cargo command.
/// * `error_message`: The error message to display if the command fails to execute.
///
/// Executes a command and provides context for any potential errors.
///
/// This macro simplifies the process of running a command and handling
/// any errors that may occur, by attaching a provided context message
/// to the resulting error. This makes error messages more informative
/// and helps in diagnosing issues more quickly.
///
/// # Parameters
///
/// * `$cmd`: The command to be executed. This should be an expression
/// that evaluates to a type implementing the `duct::cmd` interface.
/// * `$context`: A string expression providing context for the command.
/// This message will be attached to any errors that occur during the
/// execution of the command.
///
/// # Errors
///
/// If the command fails to execute, an error is returned with the
/// attached context message.
///
/// # Note
///
/// This macro requires the `duct` crate for command execution and
/// the `anyhow` crate for error handling. Ensure that these crates
/// are included in your project's dependencies and properly imported
/// in your code.
/// Executes a standard command and provides context for any potential errors.
///
/// This macro simplifies the process of running a command using `std::process::Command`
/// and handling any errors that may occur, by attaching a provided context message
/// to the resulting error. This makes error messages more informative
/// and helps in diagnosing issues more quickly.
///
/// # Parameters
///
/// * `$cmd`: The command to be executed. This should be an expression
/// that evaluates to a type implementing the `std::process::Command` interface.
/// * `$context`: A string expression providing context for the command.
/// This message will be attached to any errors that occur during the
/// execution of the command.
///
/// # Errors
///
/// If the command fails to execute, or if the command returns a non-zero exit status,
/// an error is returned with the attached context message and the command's output.
///
/// Executes a cargo command and provides context for any potential errors.
///
/// This macro is a convenience wrapper around `run_std_command`, specifically
/// tailored for executing cargo commands. It ensures consistent error handling
/// and provides informative error messages.
///
/// # Parameters
///
/// * `$args`: An expression that evaluates to an iterator of arguments for the cargo command.
/// * `$context`: A string expression providing context for the command.
///
/// # Errors
///
/// If the cargo command fails to execute, or if the command returns a non-zero exit status,
/// an error is returned with the attached context message and the command's output.
///