-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: better execution summary * fix: skip all subcommands which are q * feat: add ; separator * ci: add release workflows * release: 0.1.2
- Loading branch information
Showing
10 changed files
with
251 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
publish: | ||
name: Publish to crates.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Cargo cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cargo/registry | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo- | ||
- name: Cargo login | ||
run: cargo login ${{ secrets.CRATES_IO_TOKEN }} | ||
|
||
- name: Cargo publish | ||
run: cargo publish |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
[package] | ||
name = "cargo-q" | ||
version = "0.1.1" | ||
version = "0.1.2" | ||
edition = "2021" | ||
description = "A cargo subcommand for running multiple cargo commands in a time" | ||
keywords = ["cargo"] | ||
keywords = ["cargo", "subcommand", "plugin"] | ||
categories = ["command-line-utilities", "development-tools::cargo-plugins"] | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
repository = "https://github.com/guuzaa/cargo-q" | ||
exclude = [".github", ".vscode", ".gitignore"] | ||
|
||
[dependencies] | ||
clap = { version = "4.5", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod cli; | ||
mod executor; | ||
mod parser; | ||
mod process; | ||
mod routine; | ||
|
||
use cli::Cli; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use std::fmt; | ||
use std::time::Instant; | ||
|
||
// Terminal colors support | ||
pub trait ColorExt { | ||
fn red(self) -> ColoredString; | ||
fn green(self) -> ColoredString; | ||
fn bold(self) -> ColoredString; | ||
} | ||
|
||
impl<T: fmt::Display> ColorExt for T { | ||
fn red(self) -> ColoredString { | ||
ColoredString(format!("\x1b[31m{}\x1b[0m", self)) | ||
} | ||
fn green(self) -> ColoredString { | ||
ColoredString(format!("\x1b[32m{}\x1b[0m", self)) | ||
} | ||
fn bold(self) -> ColoredString { | ||
ColoredString(format!("\x1b[1m{}\x1b[0m", self)) | ||
} | ||
} | ||
|
||
pub struct ColoredString(String); | ||
|
||
impl fmt::Display for ColoredString { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", self.0) | ||
} | ||
} | ||
|
||
pub struct ExecutionSummary { | ||
success_count: usize, | ||
total_commands: usize, | ||
start_time: Instant, | ||
} | ||
|
||
impl ExecutionSummary { | ||
pub fn new(total_commands: usize) -> Self { | ||
Self { | ||
success_count: 0, | ||
total_commands, | ||
start_time: Instant::now(), | ||
} | ||
} | ||
|
||
pub fn increment_success(&mut self) { | ||
self.success_count += 1; | ||
} | ||
|
||
fn print_summary(&mut self) { | ||
let elapsed = self.start_time.elapsed().as_secs_f32(); | ||
let status = if self.success_count == self.total_commands { | ||
"Finished".green() | ||
} else { | ||
"Failed".red() | ||
}; | ||
println!( | ||
"\n{} {} command(s) in {:.2}s", | ||
status, self.total_commands, elapsed | ||
); | ||
if self.success_count != self.total_commands { | ||
println!( | ||
" {} succeeded, {} failed", | ||
self.success_count, | ||
self.total_commands - self.success_count | ||
); | ||
} | ||
} | ||
} | ||
|
||
impl Drop for ExecutionSummary { | ||
fn drop(&mut self) { | ||
self.print_summary(); | ||
} | ||
} |
Oops, something went wrong.