shell-rs

Crates.ioshell-rs
lib.rsshell-rs
version0.2.6
sourcesrc
created_at2019-08-22 15:19:15.200115
updated_at2022-07-13 01:35:40.435877
descriptionRust reimplementation of common coreutils APIs
homepagehttps://github.com/xushaohua/shell-rs
repositoryhttps://github.com/xushaohua/shell-rs
max_upload_size
id158894
size821,488
Xu Shaohua (XuShaohua)

documentation

README

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);

Related projects

  • 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.

Commit count: 0

cargo fmt