iocore 3.1.0

IOCore is a safe library for unix CLI tools and Systems programming. IOCore provides the [`iocore::Path`] abstraction of file-system paths designed to replace most [`std::path`] and [`std::fs`] operations with practical methods, other abstractions include: - handling file-system permissions via [`iocore::PathPermissions`] powered by the crate [`trilobyte`]. - handling file-system timestamps via [`iocore::PathTimestamps`] granularly via [`iocore::PathDateTime`]. IOCore provides the [`iocore::walk_dir`] function and its companion trait [`iocore::WalkProgressHandler`] which traverses file-systems quickly via threads. IOcore provides [`iocore::User`] which provides unix user information such as uid, path to home etc. The module [`iocore::env`] provides [`iocore::env:args`] returns a [`Vec<String>`] from [`std::env:args`], and [`iocore::env:var`] that returns environment variables as string.
Documentation
use k9::assert_equal;
use iocore::{
    Path, shell_command, shell_command_stdout, shell_command_string_output,
    shell_command_vec_output,
};
use sanitation::SString;

#[test]
fn test_shell_command_vec_output() {
    let (exit_code, out, err) = shell_command_vec_output("echo 'out'", ".").unwrap();

    assert_equal!(SString::new(&out).unchecked_safe(), "out\n");
    assert_equal!(exit_code, 0);
    assert_equal!(SString::new(&err).unchecked_safe(), "");

    let (exit_code, out, err) = shell_command_vec_output("dd if=/dev/null of=/", ".").unwrap();

    assert_equal!(exit_code, 1);
    assert_equal!(SString::new(&err).unchecked_safe().len() > 0, true);
    assert_equal!(SString::new(&out).unchecked_safe(), "");
}

#[test]
fn test_shell_command_string_output() {
    let (exit_code, out, err) = shell_command_string_output("echo -n out", ".").unwrap();

    assert_equal!(out, "out");
    assert_equal!(exit_code, 0);
    assert_equal!(err, "");

    let (exit_code, out, err) = shell_command_string_output("dd if=/dev/null of=/", ".").unwrap();

    assert_equal!(exit_code, 1);
    assert_equal!(err.len() > 0, true);
    assert_equal!(out, "");
}

#[test]
fn test_shell_command() {
    let exit_code = shell_command("test 'a z' == \"a z\"", ".").unwrap();
    assert_equal!(exit_code, 0);
}

#[test]
fn test_shell_command_stdout() {
    let stdout = shell_command_stdout("mktemp -qd", ".").unwrap();
    assert_equal!(Path::raw(stdout.trim()).exists(), true);
    assert_equal!(Path::raw(stdout.trim()).is_directory(), true);
}