Crate shell2batch
source ·Expand description
shell2batch
Coverts simple basic shell scripts to windows batch scripts.
While it is not really possible to take every shell script and automatically convert it to a windows batch file,
this library provides a way to convert simple basic shell commands to windows batch commands.
The original goal of this library is to provide users of cargo-make a
way to write simple tasks with shell scripts without duplicating their code for each platform.
Examples
extern crate shell2batch;
fn main() {
let script = shell2batch::convert(
r#"
export FILE1=file1
export FILE2=file2
#this is some test code
cp ${FILE1} $FILE2
#another
mv file2 file3
export MY_DIR=directory
#flags are supported
rm -Rf ${MY_DIR}
unset MY_DIR
"#
);
assert_eq!(
script,
r#"
set FILE1=file1
set FILE2=file2
@REM this is some test code
xcopy %FILE1% %FILE2%
@REM another
move file2 file3
set MY_DIR=directory
@REM flags are supported
rmdir /S /Q %MY_DIR%
set MY_DIR=
"#
);
println!("Script: {}", script);
}
Contributing
License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.
Functions
Converts the provided shell script and returns the windows batch script text.