├── docs ├── api │ ├── .lock │ ├── crates.js │ ├── run_script │ │ ├── types │ │ │ ├── sidebar-items.js │ │ │ ├── index.html │ │ │ └── type.ScriptResult.html │ │ ├── sidebar-items.js │ │ ├── macro.run_script!.html │ │ ├── macro.spawn_script!.html │ │ ├── macro.run_script_or_exit!.html │ │ ├── all.html │ │ ├── type.IoOptions.html │ │ ├── macro.spawn_script.html │ │ ├── type.ScriptError.html │ │ ├── fn.spawn.html │ │ ├── fn.run_or_exit.html │ │ ├── macro.run_script.html │ │ ├── macro.run_script_or_exit.html │ │ ├── fn.run.html │ │ └── type.ScriptOptions.html │ ├── src-files.js │ ├── static.files │ │ ├── favicon-32x32-6580c154.png │ │ ├── FiraMono-Medium-86f75c8c.woff2 │ │ ├── FiraSans-Italic-81dc35de.woff2 │ │ ├── FiraSans-Medium-e1aa3f0a.woff2 │ │ ├── FiraMono-Regular-87c26294.woff2 │ │ ├── FiraSans-Regular-0fe48ade.woff2 │ │ ├── NanumBarunGothic-13b3dcba.ttf.woff2 │ │ ├── SourceCodePro-It-fc8b9304.ttf.woff2 │ │ ├── SourceSerif4-It-ca3b17ed.ttf.woff2 │ │ ├── FiraSans-MediumItalic-ccf7e434.woff2 │ │ ├── SourceSerif4-Bold-6d4fd4c0.ttf.woff2 │ │ ├── SourceCodePro-Regular-8badfe75.ttf.woff2 │ │ ├── SourceSerif4-Regular-6b053e98.ttf.woff2 │ │ ├── SourceSerif4-Semibold-457a13ac.ttf.woff2 │ │ ├── SourceCodePro-Semibold-aa29a496.ttf.woff2 │ │ ├── LICENSE-MIT-23f18e03.txt │ │ ├── normalize-9960930a.css │ │ ├── scrape-examples-5e967b76.js │ │ ├── COPYRIGHT-7fb11f4e.txt │ │ ├── rust-logo-9a9549ea.svg │ │ ├── src-script-813739b1.js │ │ ├── favicon-044be391.svg │ │ ├── FiraSans-LICENSE-05ab6dbd.txt │ │ ├── SourceCodePro-LICENSE-67f54ca7.txt │ │ ├── SourceSerif4-LICENSE-a2cfd9d5.md │ │ ├── NanumBarunGothic-LICENSE-a37d393b.txt │ │ ├── storage-68b7e25d.js │ │ ├── settings-5514c975.js │ │ └── noscript-32bb7600.css │ ├── trait.impl │ │ └── core │ │ │ ├── marker │ │ │ ├── trait.Copy.js │ │ │ ├── trait.UnsafeUnpin.js │ │ │ ├── trait.StructuralPartialEq.js │ │ │ ├── trait.Send.js │ │ │ ├── trait.Sync.js │ │ │ ├── trait.Unpin.js │ │ │ └── trait.Freeze.js │ │ │ ├── error │ │ │ └── trait.Error.js │ │ │ ├── fmt │ │ │ ├── trait.Display.js │ │ │ └── trait.Debug.js │ │ │ ├── clone │ │ │ └── trait.Clone.js │ │ │ ├── cmp │ │ │ └── trait.PartialEq.js │ │ │ └── panic │ │ │ └── unwind_safe │ │ │ ├── trait.UnwindSafe.js │ │ │ └── trait.RefUnwindSafe.js │ ├── search.desc │ │ └── run_script │ │ │ └── run_script-desc-0-.js │ ├── search-index.js │ ├── settings.html │ ├── help.html │ └── type.impl │ │ └── run_script │ │ └── types │ │ ├── enum.IoOptions.js │ │ ├── struct.ScriptOptions.js │ │ └── enum.ScriptError.js └── index.html ├── .gitattributes ├── .rusty-hook.toml ├── .gitignore ├── .github ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── workflows │ └── ci.yml └── CONTRIBUTING.md ├── .editorconfig ├── Makefile.toml ├── tests ├── run_test.rs ├── run_script_or_exit_macro_test.rs ├── run_script_macro_test.rs └── spawn_script_macro_test.rs ├── benches └── bench_run.rs ├── src ├── types_test.rs ├── lib_test.rs ├── types.rs ├── macros.rs └── lib.rs ├── examples ├── function_examples.rs └── macro_examples.rs ├── Cargo.toml ├── CHANGELOG.md └── README.md /docs/api/.lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.ico binary 3 | *.woff binary 4 | -------------------------------------------------------------------------------- /.rusty-hook.toml: -------------------------------------------------------------------------------- 1 | [hooks] 2 | pre-push = "cargo make ci-flow" 3 | -------------------------------------------------------------------------------- /docs/api/crates.js: -------------------------------------------------------------------------------- 1 | window.ALL_CRATES = ["run_script"]; 2 | //{"start":21,"fragment_lengths":[12]} -------------------------------------------------------------------------------- /docs/api/run_script/types/sidebar-items.js: -------------------------------------------------------------------------------- 1 | window.SIDEBAR_ITEMS = {"enum":["IoOptions","ScriptError"],"struct":["ScriptOptions"],"type":["ScriptResult"]}; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .c9 3 | /target 4 | temp/ 5 | **/*.rs.bk 6 | Cargo.lock 7 | **/*.log 8 | dump.rdb 9 | /rs*.sh 10 | /docs/_site 11 | /core 12 | -------------------------------------------------------------------------------- /docs/api/src-files.js: -------------------------------------------------------------------------------- 1 | createSrcSidebar('[["run_script",["",[],["lib.rs","macros.rs","runner.rs","types.rs"]]]]'); 2 | //{"start":19,"fragment_lengths":[68]} -------------------------------------------------------------------------------- /docs/api/static.files/favicon-32x32-6580c154.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/favicon-32x32-6580c154.png -------------------------------------------------------------------------------- /docs/api/static.files/FiraMono-Medium-86f75c8c.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraMono-Medium-86f75c8c.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-Italic-81dc35de.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraSans-Italic-81dc35de.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-Medium-e1aa3f0a.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraSans-Medium-e1aa3f0a.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraMono-Regular-87c26294.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraMono-Regular-87c26294.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-Regular-0fe48ade.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraSans-Regular-0fe48ade.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/NanumBarunGothic-13b3dcba.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/NanumBarunGothic-13b3dcba.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-It-fc8b9304.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceCodePro-It-fc8b9304.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-It-ca3b17ed.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceSerif4-It-ca3b17ed.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-MediumItalic-ccf7e434.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/FiraSans-MediumItalic-ccf7e434.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-Bold-6d4fd4c0.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceSerif4-Bold-6d4fd4c0.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-Regular-8badfe75.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceCodePro-Regular-8badfe75.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-Regular-6b053e98.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceSerif4-Regular-6b053e98.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-Semibold-457a13ac.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceSerif4-Semibold-457a13ac.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-Semibold-aa29a496.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/run_script/HEAD/docs/api/static.files/SourceCodePro-Semibold-aa29a496.ttf.woff2 -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: '03:00' 8 | open-pull-requests-limit: 99 9 | -------------------------------------------------------------------------------- /docs/api/run_script/sidebar-items.js: -------------------------------------------------------------------------------- 1 | window.SIDEBAR_ITEMS = {"fn":["run","run_or_exit","spawn"],"macro":["run_script","run_script_or_exit","spawn_script"],"mod":["types"],"type":["IoOptions","ScriptError","ScriptOptions"]}; -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 4 11 | 12 | [*.json] 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Makefile.toml: -------------------------------------------------------------------------------- 1 | 2 | [config] 3 | additional_profiles = [ 4 | "all-default-tasks", 5 | "docs-all-modification-tasks", 6 | "ci-coverage-tasks", 7 | "ci-all-build-tasks", 8 | "ci-static-code-analysis-tasks", 9 | "publish-pre-cleanup", 10 | ] 11 | -------------------------------------------------------------------------------- /docs/api/run_script/macro.run_script!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Redirecting to macro.run_script.html...
9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/api/run_script/macro.spawn_script!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Redirecting to macro.spawn_script.html...
9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Feature Description 11 | 12 | 13 | ### Describe The Solution You'd Like 14 | 15 | 16 | ### Code Sample 17 | 18 | ```rust 19 | /// paste code here 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/api/run_script/macro.run_script_or_exit!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Redirecting to macro.run_script_or_exit.html...
9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/run_test.rs: -------------------------------------------------------------------------------- 1 | use run_script; 2 | use run_script::ScriptOptions; 3 | 4 | #[test] 5 | fn run_test() { 6 | let args = vec![]; 7 | let options = ScriptOptions::new(); 8 | 9 | let (code, output, error) = run_script::run( 10 | r#" 11 | echo "Test" 12 | exit 0 13 | "#, 14 | &args, 15 | &options, 16 | ) 17 | .unwrap(); 18 | 19 | assert_eq!(code, 0); 20 | assert!(output.len() > 0); 21 | assert_eq!(error.len(), 0); 22 | } 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Describe The Bug 11 | 12 | 13 | ### To Reproduce 14 | 15 | 16 | ### Error Stack 17 | 18 | ```console 19 | The error stack trace 20 | ``` 21 | 22 | ### Code Sample 23 | 24 | ```rust 25 | /// paste code here 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Copy.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl Copy for IoOptions"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[284]} -------------------------------------------------------------------------------- /docs/api/trait.impl/core/error/trait.Error.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl Error for ScriptError"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[291]} -------------------------------------------------------------------------------- /docs/api/trait.impl/core/fmt/trait.Display.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl Display for ScriptError"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[293]} -------------------------------------------------------------------------------- /benches/bench_run.rs: -------------------------------------------------------------------------------- 1 | #![feature(test)] 2 | extern crate test; 3 | 4 | use run_script; 5 | use run_script::ScriptOptions; 6 | use test::Bencher; 7 | 8 | #[bench] 9 | fn run(bencher: &mut Bencher) { 10 | let options = ScriptOptions::new(); 11 | 12 | let args = vec![]; 13 | 14 | bencher.iter(|| { 15 | let (code, output, error) = run_script::run( 16 | r#" 17 | echo "Test" 18 | exit 0 19 | "#, 20 | &args, 21 | &options, 22 | ) 23 | .unwrap(); 24 | 25 | assert_eq!(code, 0); 26 | assert!(output.len() > 0); 27 | assert_eq!(error.len(), 0); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | env: 4 | CLICOLOR_FORCE: 1 5 | jobs: 6 | ci: 7 | name: CI 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | rust: [stable, beta, nightly] 13 | os: [ubuntu-latest, windows-latest, macOS-latest] 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Install rust 18 | uses: dtolnay/rust-toolchain@master 19 | with: 20 | toolchain: ${{ matrix.rust }} 21 | - name: Install cargo-make 22 | run: cargo install --debug cargo-make 23 | - name: Run CI 24 | env: 25 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 26 | run: cargo make ci-flow 27 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/clone/trait.Clone.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl Clone for IoOptions"],["impl Clone for ScriptOptions"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[572]} -------------------------------------------------------------------------------- /docs/api/trait.impl/core/cmp/trait.PartialEq.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl PartialEq for IoOptions"],["impl PartialEq for ScriptOptions"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[588]} -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.UnsafeUnpin.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl UnsafeUnpin for IoOptions",1,["run_script::types::IoOptions"]],["impl UnsafeUnpin for ScriptError",1,["run_script::types::ScriptError"]],["impl UnsafeUnpin for ScriptOptions",1,["run_script::types::ScriptOptions"]]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[592]} -------------------------------------------------------------------------------- /src/types_test.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use std::error::Error; 3 | use std::io::Write; 4 | 5 | #[test] 6 | fn script_error_description() { 7 | let script_error = ScriptError::Description("test"); 8 | 9 | assert_eq!(script_error.to_string(), "test"); 10 | assert!(script_error.source().is_none()); 11 | 12 | let mut writer = Vec::new(); 13 | write!(&mut writer, "formatted {}", script_error).unwrap(); 14 | assert_eq!(writer, b"formatted test"); 15 | } 16 | 17 | #[test] 18 | fn script_options_new() { 19 | let options = ScriptOptions::new(); 20 | 21 | assert!(options.runner.is_none()); 22 | assert!(options.working_directory.is_none()); 23 | assert_eq!(options.input_redirection, IoOptions::Inherit); 24 | assert_eq!(options.output_redirection, IoOptions::Pipe); 25 | assert!(!options.exit_on_error); 26 | assert!(!options.print_commands); 27 | #[cfg(feature = "encoding_rs")] 28 | assert!(options.encoding.is_none()); 29 | } 30 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.StructuralPartialEq.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var implementors = Object.fromEntries([["run_script",[["impl StructuralPartialEq for IoOptions"],["impl StructuralPartialEq for ScriptOptions"]]]]); 3 | if (window.register_implementors) { 4 | window.register_implementors(implementors); 5 | } else { 6 | window.pending_implementors = implementors; 7 | } 8 | })() 9 | //{"start":57,"fragment_lengths":[660]} -------------------------------------------------------------------------------- /examples/function_examples.rs: -------------------------------------------------------------------------------- 1 | use run_script; 2 | use run_script::ScriptOptions; 3 | 4 | fn main() { 5 | let options = ScriptOptions::new(); 6 | 7 | let args = vec![]; 8 | 9 | // run the script and get the script execution output 10 | let (code, output, error) = run_script::run( 11 | r#" 12 | echo "Directory Info:" 13 | dir 14 | "#, 15 | &args, 16 | &options, 17 | ) 18 | .unwrap(); 19 | 20 | println!("Exit Code: {}", code); 21 | println!("Output: {}", output); 22 | println!("Error: {}", error); 23 | 24 | // run the script and get a handle to the running child process 25 | let child = run_script::spawn( 26 | r#" 27 | echo "Directory Info:" 28 | dir 29 | "#, 30 | &args, 31 | &options, 32 | ) 33 | .unwrap(); 34 | 35 | let spawn_output = child.wait_with_output().unwrap(); 36 | 37 | println!("Success: {}", &spawn_output.status.success()); 38 | } 39 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | 4 | ## Issues 5 | 6 | Found a bug? Got a question? Want some enhancement?U::from(self).\nCalls U::from(self).\nCalls U::from(self).\nReturns new instance\nDefault is IoOptions::Pipe (only pipe enables to capture …\nSets -x flag for printing each script command before …\nDefines the requested runner (defaults to cmd in windows …\nArgs for the runner (for cmd, /C will automatically be …\nThe working directory of the invocation")
--------------------------------------------------------------------------------
/docs/api/search-index.js:
--------------------------------------------------------------------------------
1 | var searchIndex = new Map(JSON.parse('[["run_script",{"t":"PPPPIPPIIOOOOOHHQQOOHQCOPPPPPGPPPGFINNNNNNNNNNNNONNONNNNNNNONNNNOOOONNNNNNNNNNNNNNNNO","n":["Description","FsIOError","IOError","Inherit","IoOptions","Null","Pipe","ScriptError","ScriptOptions","env_vars","exit_on_error","input_redirection","output_redirection","print_commands","run","run_or_exit","run_script","run_script_or_exit","runner","runner_args","spawn","spawn_script","types","working_directory","Description","Err","FsIOError","IOError","Inherit","IoOptions","Null","Ok","Pipe","ScriptError","ScriptOptions","ScriptResult","borrow","","","borrow_mut","","","clone","","clone_into","","clone_to_uninit","","env_vars","eq","","exit_on_error","fmt","","","","from","","","input_redirection","into","","","new","output_redirection","print_commands","runner","runner_args","source","to_owned","","to_string","try_from","","","try_into","","","type_id","","","vzip","","","working_directory"],"q":[[0,"run_script"],[24,"run_script::types"],[85,"core::option"],[86,"alloc::string"],[87,"alloc::vec"],[88,"std::process"],[89,"core::fmt"],[90,"core::result"],[91,"core::error"],[92,"core::any"]],"i":"C`00Cb`00``b0000````00```0BbAf11h`010```2Al13010101010010330130103010000030133013013013010","f":"`````````{bd}{bf}{bh}01{{{l{j}}{l{{A`{n}}}}{l{b}}}{{Af{{Ad{Abnn}}}}}}{{{l{j}}{l{{A`{n}}}}{l{b}}}{{Ad{nn}}}}``44{{{l{j}}{l{{A`{n}}}}{l{b}}}{{Af{Ah}}}}``5````````````{l{{l{c}}}{}}00{{{l{Aj}}}{{l{Ajc}}}{}}00{{{l{Al}}}Al}{{{l{h}}}h}{{l{l{Ajc}}}An{}}0{{lB`}An}0{Ald}{{{l{Al}}{l{Al}}}f}{{{l{h}}{l{h}}}f}{Alf}{{{l{Bb}}{l{AjBd}}}{{Bh{AnBf}}}}{{{l{Bb}}{l{AjBd}}}Bj}{{{l{Al}}{l{AjBd}}}Bj}{{{l{h}}{l{AjBd}}}Bj}{cc{}}00{Alh}{{}c{}}00{{}Al}28;;{{{l{Bb}}}{{d{{l{Bl}}}}}}{lc{}}0{ln}{c{{Bh{e}}}{}{}}00{{}{{Bh{c}}}{}}00{lBn}00{{}c{}}00{Ald}","D":"Fj","p":[[8,"ScriptOptions",0],[6,"Option",85,null,1],[1,"bool"],[6,"IoOptions",24],[1,"str"],[1,"reference",null,null,1],[5,"String",86],[5,"Vec",87],[1,"i32"],[1,"tuple",null,null,1],[8,"ScriptResult",24],[5,"Child",88],[0,"mut"],[5,"ScriptOptions",24],[1,"unit"],[1,"u8"],[6,"ScriptError",24],[5,"Formatter",89],[5,"Error",89],[6,"Result",90,null,1],[8,"Result",89],[10,"Error",91],[5,"TypeId",92],[8,"ScriptError",0],[8,"IoOptions",0]],"r":[],"b":[[52,"impl-Display-for-ScriptError"],[53,"impl-Debug-for-ScriptError"]],"c":"OjAAAAAAAAA=","e":"OzAAAAEAACAABAAlAAsAMgABADYAAgBFAA8A","P":[[36,"T"],[42,""],[44,"T"],[46,""],[56,"T"],[59,""],[60,"U"],[63,""],[69,"T"],[71,""],[72,"U,T"],[75,"U"],[78,""],[81,"V"],[84,""]]}]]'));
2 | if (typeof exports !== 'undefined') exports.searchIndex = searchIndex;
3 | else if (window.initSearch) window.initSearch(searchIndex);
4 | //{"start":39,"fragment_lengths":[2473]}
--------------------------------------------------------------------------------
/docs/api/settings.html:
--------------------------------------------------------------------------------
1 | Defines the various types and aliases.
3 |pub type ScriptResult<T> = Result<T, ScriptError>;Alias for result with script error
2 |pub enum ScriptResult<T> {
3 | Ok(T),
4 | Err(ScriptError),
5 | }macro_rules! spawn_script {
2 | ($script:expr) => { ... };
3 | ($script:expr, $options:expr) => { ... };
4 | ($script:expr, $args:expr, $options:expr) => { ... };
5 | }Enables to invoke the run_script::spawn function more easily without providing all input.
6 |script - The script contentargs - Optional, script command line arguments. If provided, the last options argument must also be provided.options - Optional, options provided to the script runner
13 | use run_script::ScriptOptions;
14 |
15 | fn main() {
16 | // simple call to run script with only the script text
17 | let child = run_script::spawn_script!(
18 | r#"
19 | echo "Test"
20 | exit 0
21 | "#
22 | ).unwrap();
23 |
24 | // run script invoked with the script text and options
25 | let options = ScriptOptions::new();
26 | let child = run_script::spawn_script!(
27 | r#"
28 | echo "Test"
29 | exit 0
30 | "#,
31 | &options
32 | ).unwrap();
33 |
34 | // run script invoked with all arguments
35 | let options = ScriptOptions::new();
36 | let child = run_script::spawn_script!(
37 | r#"
38 | echo "Test"
39 | exit 0
40 | "#,
41 | &vec!["ARG1".to_string(), "ARG2".to_string()],
42 | &options
43 | ).unwrap();
44 | }pub type ScriptError = ScriptError;Error struct
2 |pub enum ScriptError {
3 | IOError(Error),
4 | FsIOError(FsIOError),
5 | Description(&'static str),
6 | }pub fn spawn(
2 | script: &str,
3 | args: &Vec<String>,
4 | options: &ScriptOptions,
5 | ) -> ScriptResult<Child>Invokes the provided script content and returns a process handle.
6 |script - The script contentargs - The script command line argumentsoptions - Options provided to the script runneruse run_script::ScriptOptions;
14 |
15 | fn main() {
16 | let options = ScriptOptions::new();
17 |
18 | let args = vec![];
19 |
20 | let child = run_script::spawn(
21 | r#"
22 | echo "Directory Info:"
23 | dir
24 | "#,
25 | &args,
26 | &options
27 | ).unwrap();
28 | }pub fn run_or_exit(
2 | script: &str,
3 | args: &Vec<String>,
4 | options: &ScriptOptions,
5 | ) -> (String, String)Invokes the provided script content and returns the invocation output. 6 | In case of invocation error or error exit code, this function will exit the main process.
7 |script - The script contentargs - The script command line argumentsoptions - Options provided to the script runneruse run_script::ScriptOptions;
15 |
16 | fn main() {
17 | let options = ScriptOptions::new();
18 |
19 | let args = vec![];
20 |
21 | let (output, error) = run_script::run_or_exit(
22 | r#"
23 | echo "Hello World"
24 | "#,
25 | &args,
26 | &options
27 | );
28 |
29 | println!("Output: {}", output);
30 | println!("Error: {}", error);
31 | }macro_rules! run_script {
2 | ($script:expr) => { ... };
3 | ($script:expr, $options:expr) => { ... };
4 | ($script:expr, $args:expr, $options:expr) => { ... };
5 | }Enables to invoke the run_script::run function more easily without providing all input.
6 |script - The script contentargs - Optional, script command line arguments. If provided, the last options argument must also be provided.options - Optional, options provided to the script runneruse run_script::ScriptOptions;
14 |
15 | fn main() {
16 | // simple call to run script with only the script text
17 | let (code, output, error) = run_script::run_script!(
18 | r#"
19 | echo "Test"
20 | exit 0
21 | "#
22 | ).unwrap();
23 |
24 | // run script invoked with the script text and options
25 | let options = ScriptOptions::new();
26 | let (code, output, error) = run_script::run_script!(
27 | r#"
28 | echo "Test"
29 | exit 0
30 | "#,
31 | &options
32 | ).unwrap();
33 |
34 | // run script invoked with all arguments
35 | let options = ScriptOptions::new();
36 | let (code, output, error) = run_script::run_script!(
37 | r#"
38 | echo "Test"
39 | exit 0
40 | "#,
41 | &vec!["ARG1".to_string(), "ARG2".to_string()],
42 | &options
43 | ).unwrap();
44 | }macro_rules! run_script_or_exit {
2 | ($script:expr) => { ... };
3 | ($script:expr, $options:expr) => { ... };
4 | ($script:expr, $args:expr, $options:expr) => { ... };
5 | }Enables to invoke the run_script::run_or_exit function more easily without providing all input.
6 |script - The script contentargs - Optional, script command line arguments. If provided, the last options argument must also be provided.options - Optional, options provided to the script runneruse run_script::ScriptOptions;
14 |
15 | fn main() {
16 | // simple call to the macro with only the script text
17 | let (output, error) = run_script::run_script_or_exit!(
18 | r#"
19 | echo "Test"
20 | exit 0
21 | "#
22 | );
23 |
24 | // macro invoked with the script text and options
25 | let options = ScriptOptions::new();
26 | let (output, error) = run_script::run_script_or_exit!(
27 | r#"
28 | echo "Test"
29 | exit 0
30 | "#,
31 | &options
32 | );
33 |
34 | // macro invoked with all arguments
35 | let options = ScriptOptions::new();
36 | let (output, error) = run_script::run_script_or_exit!(
37 | r#"
38 | echo "Test"
39 | exit 0
40 | "#,
41 | &vec!["ARG1".to_string(), "ARG2".to_string()],
42 | &options
43 | );
44 | }pub fn run(
2 | script: &str,
3 | args: &Vec<String>,
4 | options: &ScriptOptions,
5 | ) -> ScriptResult<(i32, String, String)>Invokes the provided script content and returns the invocation output.
6 |script - The script contentargs - The script command line argumentsoptions - Options provided to the script runneruse run_script::ScriptOptions;
14 |
15 | fn main() {
16 | let options = ScriptOptions::new();
17 |
18 | let args = vec![];
19 |
20 | let (code, output, error) = run_script::run(
21 | r#"
22 | echo "Directory Info:"
23 | dir
24 | "#,
25 | &args,
26 | &options
27 | ).unwrap();
28 |
29 | println!("Exit Code: {}", code);
30 | println!("Output: {}", output);
31 | println!("Error: {}", error);
32 | }source. Read moreReturns new instance
\npub type ScriptOptions = ScriptOptions;Options available for invoking the script
2 |pub struct ScriptOptions {
3 | pub runner: Option<String>,
4 | pub runner_args: Option<Vec<String>>,
5 | pub working_directory: Option<PathBuf>,
6 | pub input_redirection: IoOptions,
7 | pub output_redirection: IoOptions,
8 | pub exit_on_error: bool,
9 | pub print_commands: bool,
10 | pub env_vars: Option<HashMap<String, String>>,
11 | }runner: Option<String>Defines the requested runner (defaults to cmd in windows and sh for other platforms)
12 |runner_args: Option<Vec<String>>Args for the runner (for cmd, /C will automatically be added at the end)
13 |working_directory: Option<PathBuf>The working directory of the invocation
14 |input_redirection: IoOptionsDefault is IoOptions::Inherit
15 |output_redirection: IoOptionsDefault is IoOptions::Pipe (only pipe enables to capture the output)
16 |exit_on_error: boolSets -e flag. Will exit on any error while running the script (not available for windows)
17 |print_commands: boolSets -x flag for printing each script command before invocation (not available for windows)
18 |env_vars: Option<HashMap<String, String>>Environment environment variables to add before invocation
19 |