10 releases

0.2.6 Jul 13, 2022
0.2.5 Sep 3, 2021
0.2.3 Aug 27, 2021
0.1.3 Aug 19, 2021
0.1.0 Aug 22, 2019

#188 in Operating systems

Download history 5/week @ 2024-02-25 87/week @ 2024-03-31

87 downloads per month

Apache-2.0

515KB
1.5K SLoC

shell-rs

shell-rs is rust reimplementation of common coreutils APIs.

Usage

Add this to Cargo.toml:

[dependencies]
shell-rs = "0.2"

Add this to your crate:

extern crate shell_rs;

Examples

Make directories recursively:

use shell_rs::{mkdir, MkDirOptions};

let mut options = MkDirOptions::new();
options.recursive = true;
options.mode = 0o700;
let ret = mkdir("/tmp/test1/test2", &options);
assert_eq!(ret, Ok(()));

Expand environment variables:

use shell_rs::expand_env;

let s = expand_env("${PWD}/a/$HOME/c.txt");
let pwd = std::env::current_dir().unwrap();
let home = std::env::home_dir().unwrap();
let s2 = format!(
    "{}/a/{}/c.txt",
    pwd.to_str().unwrap(),
    home.to_str().unwrap()
);
assert_eq!(s, s2);
  • coreutils, cross-platform Rust rewrite of the GNU coreutils
  • fs_extra, expanding opportunities standard library std::fs and std::io

License

This library is release in Apache License.

Dependencies

~9MB
~145K SLoC