No description
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| demo | ||
| doc | ||
| rush_task | ||
| rust-script-demo | ||
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
Rush
Execute shell commands with Rust. With support for handling of output and errors.
Getting started
Add dependencies in Cargo.toml
rush = { git = "https://repo.prod.meissa.de/meissa/rush.git", tag = "0.0.1" }
rush_task = { git = "https://repo.prod.meissa.de/meissa/rush.git", tag = "0.0.1" }
Using a simple command
Add imports and use function cmd
use rush::core::command::cmd;
fn hello_world() {
cmd("echo hello world");
}
Define a task (by proc macro)
use rush::core::command::cmd;
use rush_task::task;
#[task]
pub fn my_task() {
cmd("echo my first command");
cmd("echo my second command")
}
fn main() {
my_task()
}
Output
There are several options to control the printed output. E.g. to suppress result output at all use:
set_output_mode(OutputMode::Quiet);
cmd("This command does not appear in the result output");
Run with rust-script
See rust-script-demo/README.md
Sessions
There are a bunch of sessions available to run your commands either
- locally
- in a container
- as dry-run without any execution (commands are only printed)
Example for a container session:
use rush::core::command::{cmd};
use rush::core::file_io::{create_dirs, create_file};
use rush::core::session::{default_container_session};
fn main() {
default_container_session(|| {
cmd("echo hello from container!");
// create folders and file
create_dirs_in_current_dir("folder1/folder2");
create_file("test-file.txt", "Hello from test file.\n", "folder1/folder2");
cmd("echo good bye from session!");
});
}
Output
You'll get an overview of all tasks and commands executed and if they succeeded, e.g.:
=============== Start ===============
---> Success task_a
-----> Success task_b
-----> Success task_c
-> Success task_d
=============== End ================
Examples
A bunch of examples can be found in: main.rs
Principles
Api architecture
License
MIT License.
Project status
Under development.