Go to file
Ivan Bushchik dcbb036760
0.3.1
- export shell::run

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
2024-01-03 16:33:21 +03:00
src 0.3.1 2024-01-03 16:33:21 +03:00
.gitignore Initial commit 2023-03-17 15:25:50 +03:00
.rustfmt.toml Initial commit 2023-03-17 15:24:28 +03:00
Cargo.toml 0.3.1 2024-01-03 16:33:21 +03:00
LICENSE Initial commit 2023-03-17 15:24:28 +03:00
README.md 0.3.0 2023-09-14 18:40:07 +03:00

SmURF

SMall Useful Rust Functions

Components

IO

  • macros input!(T) and input_vec!(T), that could be used to simplify stdin process
  • read_file_str() basically reads file to string (yes.)
  • read_file_bytes() see read_file_str()

Shell

  • macros shell!()

Usage

Add this to your Cargo.toml:

[dependencies]
smurf = "0.3"

and this to your crate root:

extern crate smurf;

Example

use smurf;
use std::io::Write;

fn main() {
	print!("What is your name? ");
	std::io::stdout().flush().unwrap();
	let user_name = input!(String);
	print!("What is your age? ");
	std::io::stdout().flush().unwrap();
	let user_age = input!(u8);
	let shell_output = shell!("echo Hello {} of age {}", user_name, user_age); // Returns ShellResult {code: i32, stdout: String, stderr: String}
	println!("Shell output: {}", shell_output.stdout);
	println!("Shell stderr: {}", shell_output.stderr);
	println!("Shell exit code: {}", shell_output.code);
}

License

MIT