|
112 | 112 | //! |
113 | 113 | //! - [`run_fun!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.run_fun.html) -> [`FunResult`](https://docs.rs/cmd_lib/latest/cmd_lib/type.FunResult.html) |
114 | 114 | //! |
115 | | -//! ``` |
116 | | -//! # use cmd_lib::run_fun; |
| 115 | +//! ```no_run |
| 116 | +//! # use cmd_lib::{info, run_fun}; |
117 | 117 | //! let version = run_fun!(rustc --version | awk r"{print $2}")?; |
118 | | -//! eprintln!("Your rust version is {}", version); |
119 | | -//! |
120 | | -//! // with pipes |
121 | | -//! let n = run_fun!(echo "the quick brown fox jumped over the lazy dog" | wc -w)?; |
122 | | -//! eprintln!("There are {} words in above sentence", n); |
| 118 | +//! info!("Your rust version is {version}"); |
123 | 119 | //! # Ok::<(), std::io::Error>(()) |
124 | 120 | //! ``` |
125 | 121 | //! |
|
293 | 289 | //! ### Macro to register your own commands |
294 | 290 | //! Declare your function with the right signature, and register it with [`use_custom_cmd!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.use_custom_cmd.html) macro: |
295 | 291 | //! |
296 | | -//! ``` |
| 292 | +//! ```no_run |
297 | 293 | //! # use cmd_lib::*; |
298 | 294 | //! # use std::io::Write; |
299 | 295 | //! fn my_cmd(env: &mut CmdEnv) -> CmdResult { |
|
317 | 313 | //! - [`tls_init!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_init.html) to define thread local global variable |
318 | 314 | //! - [`tls_get!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_get.html) to get the value |
319 | 315 | //! - [`tls_set!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_set.html) to set the value |
320 | | -//! ``` |
| 316 | +//! ```no_run |
321 | 317 | //! # use cmd_lib::{ tls_init, tls_get, tls_set }; |
322 | 318 | //! tls_init!(DELAY, f64, 1.0); |
323 | 319 | //! const DELAY_FACTOR: f64 = 0.8; |
|
347 | 343 | //! ### Security Notes |
348 | 344 | //! Using macros can actually avoid command injection, since we do parsing before variable substitution. |
349 | 345 | //! For example, below code is fine even without any quotes: |
350 | | -//! ``` |
| 346 | +//! ```no_run |
351 | 347 | //! # use cmd_lib::{run_cmd, CmdResult}; |
352 | 348 | //! # use std::path::Path; |
353 | 349 | //! fn cleanup_uploaded_file(file: &Path) -> CmdResult { |
|
0 commit comments