2 Commits

Author SHA1 Message Date
ac948f193b chore: Release 2025-01-30 22:02:21 -05:00
2d7d6cf641 fix: Better enforce typing for commands 2025-01-30 22:02:07 -05:00
5 changed files with 36 additions and 9 deletions

View File

@@ -2,12 +2,22 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [1.3.1] - 2025-01-31
### 🐛 Bug Fixes
- Better enforce typing for commands
## [1.3.0] - 2025-01-31 ## [1.3.0] - 2025-01-31
### 🚀 Features ### 🚀 Features
- Pipe - Pipe
### ⚙️ Miscellaneous Tasks
- Release
## [1.2.0] - 2025-01-14 ## [1.2.0] - 2025-01-14
### 🚀 Features ### 🚀 Features

4
Cargo.lock generated
View File

@@ -40,7 +40,7 @@ dependencies = [
[[package]] [[package]]
name = "comlexr" name = "comlexr"
version = "1.3.0" version = "1.3.1"
dependencies = [ dependencies = [
"comlexr_macro", "comlexr_macro",
"rstest", "rstest",
@@ -51,7 +51,7 @@ dependencies = [
[[package]] [[package]]
name = "comlexr_macro" name = "comlexr_macro"
version = "1.3.0" version = "1.3.1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -4,7 +4,7 @@ members = ["macro"]
[workspace.package] [workspace.package]
description = "Dynamically build Command objects with conditional expressions" description = "Dynamically build Command objects with conditional expressions"
repository = "https://gitlab.com/wunker-bunker/comlexr" repository = "https://gitlab.com/wunker-bunker/comlexr"
version = "1.3.0" version = "1.3.1"
edition = "2021" edition = "2021"
rust-version = "1.60" rust-version = "1.60"
license = "MIT" license = "MIT"
@@ -43,7 +43,7 @@ pre-release-replacements = [
all-features = true all-features = true
[dependencies] [dependencies]
comlexr_macro = { version = "=1.3.0", path = "./macro" } comlexr_macro = { version = "=1.3.1", path = "./macro" }
thiserror = "1.0.65" thiserror = "1.0.65"
[dev-dependencies] [dev-dependencies]

View File

@@ -8,7 +8,7 @@ Add `comlexr` to your project's `Cargo.toml`:
```toml ```toml
[dependencies] [dependencies]
comlexr = "1.3.0" comlexr = "1.3.1"
``` ```
## MSRV ## MSRV

View File

@@ -6,7 +6,7 @@ use syn::{
Error, Token, Error, Token,
}; };
use crate::{cmd::Value, macros::enum_to_tokens}; use crate::cmd::Value;
pub struct Pipe { pub struct Pipe {
stdin: Option<Value>, stdin: Option<Value>,
@@ -47,7 +47,7 @@ impl ToTokens for Pipe {
let first_command = commands_iter.next().unwrap(); let first_command = commands_iter.next().unwrap();
let initial = quote! { let initial = quote! {
let mut _c_0 = #first_command; let mut _c_0: #first_command;
_c_0.stdout(::std::process::Stdio::piped()); _c_0.stdout(::std::process::Stdio::piped());
_c_0.stdin(::std::process::Stdio::piped()); _c_0.stdin(::std::process::Stdio::piped());
let mut _child_0 = _c_0.spawn()?; let mut _child_0 = _c_0.spawn()?;
@@ -95,7 +95,7 @@ impl ToTokens for Pipe {
}); });
} }
let mut #com_ident = #command; let mut #com_ident: #command;
#com_ident.stdout(::std::process::Stdio::piped()); #com_ident.stdout(::std::process::Stdio::piped());
#com_ident.stdin(::std::process::Stdio::piped()); #com_ident.stdin(::std::process::Stdio::piped());
@@ -171,4 +171,21 @@ impl Parse for CommandExpr {
} }
} }
enum_to_tokens! {CommandExpr: Macro, Reference, Function, Block} impl ToTokens for CommandExpr {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
tokens.extend(match self {
Self::Macro(macr) => quote! {
::std::process::Command = #macr
},
Self::Reference(refer) => quote! {
&mut ::std::process::Command = #refer
},
Self::Function(fun) => quote! {
::std::process::Command = #fun
},
Self::Block(block) => quote! {
::std::process::Command = #block
},
});
}
}