https://github.com/feenkcom/gtoolkit-external-process
A Pharo library for cross-platform running of external commands and getting their output.
https://github.com/feenkcom/gtoolkit-external-process
Last synced: 9 months ago
JSON representation
A Pharo library for cross-platform running of external commands and getting their output.
- Host: GitHub
- URL: https://github.com/feenkcom/gtoolkit-external-process
- Owner: feenkcom
- License: mit
- Created: 2021-10-07T13:50:46.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T10:54:48.000Z (over 1 year ago)
- Last Synced: 2025-02-21T11:44:17.202Z (over 1 year ago)
- Language: Smalltalk
- Size: 138 KB
- Stars: 5
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gtoolkit-external-process
A Pharo library for cross-platform running of external commands and getting their output.
## Supported platforms:
Linux, Windows, MacOS
## How to load
Compile or download a released shared library for your platform from https://github.com/feenkcom/libprocess/releases and place it in the same folder as `GlamorousToolkit.image` or in the corresponding libraries folder inside of the `GlamorousToolkit` app.
```smalltalk
Metacello new
baseline: 'GToolkitExternalProcess';
repository: 'github://feenkcom/gtoolkit-external-process:main/src';
load.
```
## Usage
### Synchronous output
Create an external command with a builder and spawn a child process or wait for the output. Then get the output status, stdout or stderr:
```smalltalk
output := GtExternalProcessBuilder new
command: 'ls';
arg: '-la';
output.
output stdoutString
```
### Buffered non-blocking IO
Pipe the stdout or stderr and poll regularly from an asynchronousStdout:
```smalltalk
child := GtExternalProcessBuilder new
command: 'ping';
arg: 'google.com';
pipeStdout;
spawn.
child asynchronousStdout
pollStringEvery: 1 second
do: [ :aString | aString trace ].
"kill when done"
child kill.
```