Skip to content

Commit a9a317e

Browse files
committed
Merge branch 'test'
2 parents 37b8c93 + 4c6dbc4 commit a9a317e

File tree

11 files changed

+64
-20
lines changed

11 files changed

+64
-20
lines changed

.idea/kommand.iml

-8
This file was deleted.

.idea/material_theme_project_new.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

-8
This file was deleted.

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "com.kgit2"
10-
version = "2.0.2"
10+
version = "2.1.0"
1111

1212
repositories {
1313
mavenCentral()

kommand-core/.idea/material_theme_project_new.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kommand-core/justfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ prepare:
66
brew install x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
77

88
leaks:
9-
cargo build
9+
cargo build --package kommand-core --package kommand-echo
1010
leaks -atExit -- target/debug/leaks_test
1111

1212
bench:

kommand-core/src/bin/leaks_test.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use kommand_core::io::{drop_stdout, read_line_stdout};
55
use kommand_core::process::{buffered_stdout_child, Stdio};
66
use kommand_core::process::{drop_child, wait_child};
77
use kommand_core::process::{drop_command, new_command, spawn_command, stdout_command};
8+
use kommand_core::result::ErrorType;
89

910
fn main() {
1011
unsafe {
@@ -31,7 +32,10 @@ fn main() {
3132
let line = if !result.ok.is_null() {
3233
into_string(result.ok as *mut c_char)
3334
} else {
34-
panic!("{}", into_string(result.err))
35+
match result.error_type {
36+
ErrorType::None => String::new(),
37+
_ => panic!("{}", into_string(result.err)),
38+
}
3539
};
3640
println!("[{i}] line {}", line);
3741
if line.is_empty() {

src/commonMain/kotlin/com/kgit2/kommand/process/Command.kt

+4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ expect class Command(command: String) {
1212

1313
fun args(args: List<String>): Command
1414

15+
fun args(vararg args: String): Command
16+
1517
fun env(key: String, value: String): Command
1618

1719
fun envs(envs: Map<String, String>): Command
1820

21+
fun envs(vararg envs: Pair<String, String>): Command
22+
1923
fun removeEnv(key: String): Command
2024

2125
fun envClear(): Command

src/jvmMain/kotlin/com/kgit2/kommand/process/Command.jvm.kt

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ actual class Command(
3030
return this
3131
}
3232

33+
actual fun args(vararg args: String): Command {
34+
builder.command().addAll(args)
35+
return this
36+
}
37+
3338
actual fun env(key: String, value: String): Command {
3439
builder.environment()[key] = value
3540
return this
@@ -40,6 +45,11 @@ actual class Command(
4045
return this
4146
}
4247

48+
actual fun envs(vararg envs: Pair<String, String>): Command {
49+
builder.environment().putAll(envs)
50+
return this
51+
}
52+
4353
actual fun removeEnv(key: String): Command {
4454
builder.environment().remove(key)
4555
return this
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
headers = kommand_core.h
22
staticLibraries = libkommand_core.a
33
compilerOpts = -Ikommand-core
4-
linkerOpts = -static -lws2_32 -lbcrypt -luserenv -lntdll -v
4+
linkerOpts = -static -lws2_32 -lbcrypt -luserenv -lntdll -lstdc++ -v
55
libraryPaths = kommand-core/target/x86_64-pc-windows-gnu/release

src/nativeMain/kotlin/com/kgit2/kommand/process/Command.native.kt

+14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ actual class Command(
5252
return this
5353
}
5454

55+
actual fun args(vararg args: String): Command {
56+
for (arg in args) {
57+
arg_command(inner, arg)
58+
}
59+
return this
60+
}
61+
5562
actual fun env(key: String, value: String): Command {
5663
env_command(inner, key, value)
5764
return this
@@ -64,6 +71,13 @@ actual class Command(
6471
return this
6572
}
6673

74+
actual fun envs(vararg envs: Pair<String, String>): Command {
75+
for ((key, value) in envs) {
76+
env_command(inner, key, value)
77+
}
78+
return this
79+
}
80+
6781
actual fun removeEnv(key: String): Command {
6882
remove_env_command(inner, key)
6983
return this

0 commit comments

Comments
 (0)