https://github.com/suolapeikko/taskutils
Command line app example for class that runs piped commands using Process
https://github.com/suolapeikko/taskutils
cli macos swift
Last synced: 2 days ago
JSON representation
Command line app example for class that runs piped commands using Process
- Host: GitHub
- URL: https://github.com/suolapeikko/taskutils
- Owner: suolapeikko
- Created: 2017-10-04T18:25:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-28T10:18:50.000Z (about 8 years ago)
- Last Synced: 2026-07-08T21:06:27.725Z (3 days ago)
- Topics: cli, macos, swift
- Language: Swift
- Homepage:
- Size: 14.6 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# taskutils
Command line app example for class that runs piped commands using Process.
## Usage
See main.swift for example:
```
// Create example command line interface commands that needs to be run chained / piped
let psefCommand = CliCommand(launchPath: "/bin/ps", arguments: ["-e", "-f"])
let grepMdworkerCommand = CliCommand(launchPath: "/usr/bin/grep", arguments: ["mdworker"])
// Prepare cli command runner
let chainedCommand = CliCommandRunner(commands: [psefCommand, grepMdworkerCommand])
// Prepare result tuple
var chainedCommandResult: String?
// Execute cli commands and prepare for exceptions
do {
chainedCommandResult = try chainedCommand.execute()
}
catch CliError.no_TASKS{
print("Empty task array")
exit(0)
}
catch CliError.execute_FAILED(let statusCode, let resultText){
print("Execute failed: status code=\(statusCode), result text=\(resultText)")
exit(0)
}
print("Command output: \(chainedCommandResult!)")
```