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
//! Run shell scripts inline with your rust code //! //! # Example //! ``` //! #![feature(proc_macro_hygiene)] //! use cmd_macro::cmd; //! //! fn main() { //! let who = "world"; //! let output = cmd!(echo hello #who ##who).unwrap(); //! let output = String::from_utf8(output.stdout).unwrap(); //! assert_eq!(output, "hello world #who\n"); //! //! let s = "seq"; //! let n = 3; //! let output = cmd!(#s #{2 * n}).unwrap(); //! let output = String::from_utf8(output.stdout).unwrap(); //! assert_eq!(output, "1\n2\n3\n4\n5\n6\n"); //! } //! ``` /// Run a series of commands /// /// # Example /// ``` /// #![feature(proc_macro_hygiene)] /// use cmd_macro::cmd; /// /// fn main() { /// let who = "world"; /// let output = cmd!(echo hello #who ##who).unwrap(); /// let output = String::from_utf8(output.stdout).unwrap(); /// assert_eq!(output, "hello world #who\n"); /// /// let s = "seq"; /// let n = 3; /// let output = cmd!(#s #{2 * n}).unwrap(); /// let output = String::from_utf8(output.stdout).unwrap(); /// assert_eq!(output, "1\n2\n3\n4\n5\n6\n"); /// } /// ``` pub use cmd_derive::cmd;