#scripting #shell #batch #conversion

shell2batch

Coverts simple basic shell scripts to windows batch scripts

24 releases

new 0.1.23 Aug 9, 2018
0.1.22 Jul 22, 2018
0.1.21 Jun 22, 2018
0.1.17 Mar 20, 2018
0.1.6 Nov 3, 2017

#8 in Command line utilities

Download history 428/week @ 2018-05-18 265/week @ 2018-05-25 824/week @ 2018-06-01 237/week @ 2018-06-08 242/week @ 2018-06-15 220/week @ 2018-06-22 342/week @ 2018-06-29 145/week @ 2018-07-06 193/week @ 2018-07-13 144/week @ 2018-07-20 608/week @ 2018-07-27 397/week @ 2018-08-03 708/week @ 2018-08-10

1,584 downloads per month

shell2batch

crates.io Build Status Build status codecov
license Libraries.io for GitHub Documentation downloads
Built with cargo-make

Coverts simple basic shell scripts to windows batch scripts.

Overview

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.

Usage

Simply include the library and invoke the convert function as follows:

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
del /Q %MY_DIR%

set MY_DIR=
"#
    );

    println!("Script: {}", script);
}

Installation

In order to use this library, just add it as a dependency:

[dependencies]
shell2batch = "*"

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

Date Version Description
2018-08-09 v0.1.23 Maintenance
2017-10-24 v0.1.4 Variable replacement support.
2017-10-22 v0.1.2 Added command flags replacements.
2017-10-21 v0.1.0 Initial release.

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.

Apache-2.0 license

Dependencies

Reverse deps