@@ -4,7 +4,7 @@ use quote::quote;
44
55/// Mark main function to log error result by default.
66///
7- /// ```
7+ /// ```no_run
88/// # use cmd_lib::*;
99///
1010/// #[cmd_lib::main]
@@ -41,8 +41,9 @@ pub fn main(
4141}
4242
4343/// Import user registered custom command.
44- /// ```
44+ /// ```no_run
4545/// # use cmd_lib::*;
46+ /// # use std::io::Write;
4647/// fn my_cmd(env: &mut CmdEnv) -> CmdResult {
4748/// let msg = format!("msg from foo(), args: {:?}", env.get_args());
4849/// writeln!(env.stderr(), "{msg}")?;
@@ -79,7 +80,7 @@ pub fn use_custom_cmd(item: proc_macro::TokenStream) -> proc_macro::TokenStream
7980}
8081
8182/// Run commands, returning [`CmdResult`](../cmd_lib/type.CmdResult.html) to check status.
82- /// ```
83+ /// ```no_run
8384/// # use cmd_lib::run_cmd;
8485/// let msg = "I love rust";
8586/// run_cmd!(echo $msg)?;
@@ -116,7 +117,7 @@ pub fn run_cmd(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
116117}
117118
118119/// Run commands, returning [`FunResult`](../cmd_lib/type.FunResult.html) to capture output and to check status.
119- /// ```
120+ /// ```no_run
120121/// # use cmd_lib::run_fun;
121122/// let version = run_fun!(rustc --version)?;
122123/// println!("Your rust version is {}", version);
@@ -138,10 +139,10 @@ pub fn run_fun(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
138139}
139140
140141/// Run commands with/without pipes as a child process, returning [`CmdChildren`](../cmd_lib/struct.CmdChildren.html) result.
141- /// ```
142+ /// ```no_run
142143/// # use cmd_lib::*;
143144///
144- /// let handle = spawn!(ping -c 10 192.168.0.1)?;
145+ /// let mut handle = spawn!(ping -c 10 192.168.0.1)?;
145146/// // ...
146147/// if handle.wait().is_err() {
147148/// // ...
@@ -159,20 +160,20 @@ pub fn spawn(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
159160}
160161
161162/// Run commands with/without pipes as a child process, returning [`FunChildren`](../cmd_lib/struct.FunChildren.html) result.
162- /// ```
163+ /// ```no_run
163164/// # use cmd_lib::*;
164165/// let mut procs = vec![];
165166/// for _ in 0..4 {
166167/// let proc = spawn_with_output!(
167- /// sudo bash -c "dd if=$file of=/dev/null bs=$block_size skip=$off count=$cnt 2>&1"
168+ /// sudo bash -c "dd if=/dev/nvmen0 of=/dev/null bs=4096 skip=0 count=1024 2>&1"
168169/// | awk r#"/copied/{print $(NF-1) " " $NF}"#
169170/// )?;
170171/// procs.push(proc);
171172/// }
172173///
173174/// for (i, mut proc) in procs.into_iter().enumerate() {
174175/// let bandwidth = proc.wait_with_output()?;
175- /// info!("thread {i} bandwidth: {bandwidth} MB/s")? ;
176+ /// info!("thread {i} bandwidth: {bandwidth} MB/s");
176177/// }
177178/// # Ok::<(), std::io::Error>(())
178179/// ```
@@ -192,8 +193,8 @@ pub fn spawn_with_output(input: proc_macro::TokenStream) -> proc_macro::TokenStr
192193/// Log a fatal message at the error level, and exit process.
193194///
194195/// e.g:
195- /// ```
196- /// # use cmd_lib::cmd_die ;
196+ /// ```no_run
197+ /// # use cmd_lib::* ;
197198/// let file = "bad_file";
198199/// cmd_die!("could not open file: $file");
199200/// // output:
0 commit comments