elsa-workflows / elsa-workflows/elsa-extensions
Add Command Line Integration
- Dominant language
- C#
- Stars
- 49
- Forks
- 48
- Avg merge
- 21h 35m
- Merged PRs (30d)
- 20
Description
## Feature Request
### Problem Overview
Provide a way to invoke command line tools to make Elsa more extensible. There are a vast amount of CLI tools out there that expose deep functionality (sometimes beyond what .NET can provide) and exposing them to work generically with Elsa would be a big step forward.
### Proposed Solution
Add a new activity that integrates and exposes the **[CliWrap package](https://github.com/Tyrrrz/CliWrap)** as a new activity called `InvokeCommand` that provides a strongly-typed abstraction over the `System.Diagnostics.Process`. This activity would offer flexible support for piping one CLI command into another by exposing the CliWrap object reference as an output on the activity so it can optionally be fed into another `InvokeCommand` activity.
#### Activity Inputs:
- **Command :** A CliWrap Command object OR an auto-complete of the existing executable files found on the system PATH. The user can also free-form type the command name if their command was not found.
- **Arguments:** an array of arguments for the command OR a single string containing the entire set of arguments.
- **Working Directory:** An optional working directory path.
- **Environment Variables:** A list of key/value pairs of environment variables to run the command with.
- **Credentials:** Sets domain, name and password of the user, under whom the child process should be started if different from the current process's identity.
- **Successful Exit Code:** A numeric integer for validating the result of an execution. Validation is disable if this is left blank.
- **Successful Output Text:** A string contained in the standard output of the result of an execution. Regular expressions are supported. Validation is disable if this is left blank.
- **Timeout:** Abortion mechanism to stop the execution before it finishes.
#### Activity Outputs:
- **Command:** The CliWrap command instance that was used to invoke the CLI command. Useful for piping into another `InvokeCommand` activity.
- **IsSuccess:** (bool) - true if `Successful Exit Code` and `Successful Output Text` are true OR true if they are disabled.
- **StandardOutput:** (string)
- **StandardError:** (string)
- **ExitCode:** (int)
- **StartTime:** (DateTimeOffset)
- **ExitTime:** (DateTimeOffset)
- **RunTime:** (TimeSpan)
### Use Cases
- I want to run `ffmpeg` to encode a video stream so I called the `InvokeCommand` activity to do it and then process the output of the command in another activity.
- I want to run `robocopy` to sync a file system from one directory to another periodically so I invoke cron to run every hour followed by the InvokeCommand to call robocopy.
Contributor guide
Assessment
This issue has not been assessed yet.