You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,11 +228,10 @@ run_cmd!(info "This is an infomation message")?;
228
228
```
229
229
230
230
#### Macros to register your own commands
231
-
Declare your function with `#[export_cmd(..)]` attribute, and import it with [`use_custom_cmd!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.use_custom_cmd.html) macro:
231
+
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:
232
232
233
233
```rust
234
-
#[export_cmd(my_cmd)]
235
-
fnfoo(env:&mutCmdEnv) ->CmdResult {
234
+
fnmy_cmd(env:&mutCmdEnv) ->CmdResult {
236
235
letmsg=format!("msg from foo(), args: {:?}", env.args());
Copy file name to clipboardExpand all lines: src/lib.rs
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -251,13 +251,12 @@
251
251
//! ```
252
252
//!
253
253
//! ### Macros to register your own commands
254
-
//! Declare your function with `#[export_cmd(..)]` attribute, and import it with [`use_custom_cmd!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.use_custom_cmd.html) macro:
254
+
//! 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:
255
255
//!
256
256
//! ```
257
257
//! # use cmd_lib::*;
258
258
//! # use std::io::Write;
259
-
//! #[export_cmd(my_cmd)]
260
-
//! fn foo(env: &mut CmdEnv) -> CmdResult {
259
+
//! fn my_cmd(env: &mut CmdEnv) -> CmdResult {
261
260
//! let msg = format!("msg from foo(), args: {:?}", env.args());
0 commit comments