https://github.com/lndbrg/java-async-process
A small library that wraps process execution in completable futures.
https://github.com/lndbrg/java-async-process
completablefuture future futures java java-8 java-library java8 process
Last synced: 10 months ago
JSON representation
A small library that wraps process execution in completable futures.
- Host: GitHub
- URL: https://github.com/lndbrg/java-async-process
- Owner: lndbrg
- License: apache-2.0
- Created: 2017-01-20T11:16:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-15T00:18:20.000Z (over 8 years ago)
- Last Synced: 2025-01-31T13:26:30.025Z (11 months ago)
- Topics: completablefuture, future, futures, java, java-8, java-library, java8, process
- Language: Java
- Size: 43 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Async Process
=============
[]()
[]()
[]()
[](https://codebeat.co/projects/github-com-lndbrg-java-async-process-master)
Small library for making it easier to spawn processes in java with a modern api.
Usage
-----
AysncProcess comes with a few static methods, to either create a builder that can be launched by
calling `start()`.
Prepare a command and then spawn it:
```java
AsyncProcess.cmd("echo", "foo").start();
```
Or calling the `run()` method to directly spawn a command
```java
AsyncProcess.run("echo", "foo");
```
The run method is overloaded to make it possible to directly spawn commands with stdin/out/err set,
it is recommended to use the builder created by the cmd builder in order to get clearer code though.
### Advanced usage
Here the cmd method is imported statically:
```java
cmd("echo", "foo")
.in(supplier)
.out(consumer)
.err(consumer)
.start();
```
In sets the stdin supplier, expected to be of type `Supplier` it expected to block when it
doesn't have data and the supplier will never be called again after supplying a null value.
### In `pom.xml`
```xml
sh.nerd
async-process
$VERSION
```
Todo
----
- [x] Give the user the possibility to specify environment through a hashmap
- [ ] Go through handling of the communication threads and verify the paths
- [ ] Better documentation
- [x] Any other TODOs in the code.