5 Commits
1.0.8 ... 1.0.9

Author SHA1 Message Date
1eb9c5c17d Added multiple -e 2023-09-07 17:40:37 +03:00
70136e9074 Improve readability 2023-09-07 16:05:38 +03:00
2334c1a8f3 Fix logging 2023-09-07 15:34:13 +03:00
da6ae2ce37 Improve readability 2023-09-07 15:33:15 +03:00
e2cc36adf1 Drop ARM build 2023-09-07 15:06:24 +03:00
4 changed files with 33 additions and 61 deletions

View File

@ -1,39 +0,0 @@
name: ARM Rust static build and publish
on: ["push"]
# push:
# tags:
# - '*'
#
env:
CARGO_TERM_COLOR: always
BUILD_TARGET: x86_64-unknown-linux-musl
BINARY_NAME: rexec
jobs:
build:
name: Build static binary
runs-on: self-hosted
container:
image: rust:latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# - name: Build-musl
# uses: gmiam/rust-musl-action@master
# with:
# args: cargo build --target $BUILD_TARGET --release
- name: Deps
run: |
rustup target add x86_64-unknown-linux-musl
cargo build --target ${{ env.BUILD_TARGET }} --release
- name: Get version
run: echo "VERSION=$(grep -P '^version = \"\d+\.\d+\.\d+\"' Cargo.toml | awk -F '\"' '{print $2}')" >> $GITHUB_ENV
- name: Show version
run: echo ${{ env.VERSION }}
- uses: actions/upload-artifact@v3.1.2
name: Upload artifact
with:
name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }}
path: target/${{ env.BUILD_TARGET }}/release/${{ env.BINARY_NAME }}

2
Cargo.lock generated
View File

@ -1066,7 +1066,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]]
name = "rexec"
version = "1.0.8"
version = "1.0.9"
dependencies = [
"brace-expand",
"clap 4.3.4",

View File

@ -1,6 +1,6 @@
[package]
name = "rexec"
version = "1.0.8"
version = "1.0.9"
readme = "https://github.com/house-of-vanity/rexec#readme"
edition = "2021"
description = "Parallel SSH executor"

View File

@ -34,9 +34,10 @@ struct Args {
#[arg(
short,
long,
num_args = 1..,
help = "Expression to build server list. List and range expansion are supported. Example: 'web-[1:12]-io-{prod,dev}'"
)]
expression: String,
expression: Vec<String>,
#[arg(short, long, help = "Command to execute on servers")]
command: String,
@ -156,22 +157,30 @@ fn main() {
let hosts = if args.known_hosts {
info!("Using ~/.ssh/known_hosts to build server list.");
let known_hosts = read_known_hosts();
// Build regex
let re = match Regex::new(&args.expression) {
Ok(result) => result,
Err(e) => {
error!("Error parsing regex. {}", e);
process::exit(1);
}
};
// match hostnames from known_hosts to regex
known_hosts
.into_iter()
.filter(|r| re.is_match(&r.name.clone()))
.collect()
let mut all_hosts = Vec::new();
for expression in args.expression.iter() {
let re = match Regex::new(expression) {
Ok(result) => result,
Err(e) => {
error!("Error parsing regex. {}", e);
process::exit(1);
}
};
let matched: Vec<Host> = known_hosts
.clone()
.into_iter()
.filter(|r| re.is_match(&r.name.clone()))
.collect();
all_hosts.extend(matched);
}
all_hosts
} else {
info!("Using string expansion to build server list.");
expand_string(&args.expression)
let mut all_hosts = Vec::new();
for expression in args.expression.iter() {
all_hosts.extend(expand_string(expression));
}
all_hosts
};
// Dedup hosts from known_hosts file
@ -270,7 +279,7 @@ fn main() {
println!(
"{}",
format!(
"Exit code [{}] / stdout {} bytes / stderr {} bytes",
"Exit code [{}] | std out/err [{}/{}] bytes",
code_string,
output.stdout.len(),
output.stderr.len()
@ -283,10 +292,13 @@ fn main() {
Ok(stdout) => match stdout.as_str() {
"" => {}
_ => {
println!("{}", "STDOUT".bold().blue());
let prefix = if output.exit_status != 0 {
format!("{}", "".cyan())
} else {
format!("{}", "".green())
};
for line in stdout.lines() {
println!("{} {}", "".green(), line);
println!("{} {}", prefix, line);
}
}
},
@ -296,7 +308,6 @@ fn main() {
Ok(stderr) => match stderr.as_str() {
"" => {}
_ => {
println!("{}", "STDERR".bold().bright_red());
for line in stderr.lines() {
println!("{} {}", "".red(), line);
}