facades add a new core module: Process, it's simpler to call system commands in your application. It has been merged to the master branch, thanks to the core developer @kkumargcc for the contribution.
Core Features
- Use the
Runfunction to execute one command. - Use the
Pipefunction to execute multiple commands. - Use the
Poolfunction to execute command concurrently. - Provide multiple functions to judge and operate the execution result.
Usage Guide
// Run
result, err := facades.Process().Run("echo", "Hello, World!")
// Pipe
result, err := facades.Process().Pipe(func(pipe contracts.Pipe) {
pipe.Command("echo", "Hello, World!")
pipe.Command("grep", "World")
pipe.Command("tr", "a-z", "A-Z")
}).Run()
// Pool
poolResults, err := facades.Process().Pool(func(pool contracts.Pool) {
pool.Command("sleep", "1").As("sleep1")
pool.Command("echo", "hello").As("echo1")
pool.Command("echo", "world").As("echo2")
}).Run()
For details in PR: https://github.com/goravel/framework/pull/1232
Top comments (0)