mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-01 11:01:52 -06:00
FF-1698: C# scripts!
This commit is contained in:
51
BasicNodes/Scripting/ShellScript.cs
Normal file
51
BasicNodes/Scripting/ShellScript.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BasicNodes.Scripting;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
|
||||
namespace FileFlows.BasicNodes.Scripting;
|
||||
|
||||
/// <summary>
|
||||
/// Flow element that executes a Shell script
|
||||
/// </summary>
|
||||
public class ShellScript : ScriptBase
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Icon => "svg:sh";
|
||||
/// <inheritdoc />
|
||||
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/shell-script";
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override ScriptLanguage Language => ScriptLanguage.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the code to execute
|
||||
/// </summary>
|
||||
[Required]
|
||||
[DefaultValue(@"
|
||||
# A Shell script can communicate with FileFlows to determine which output to call next by using exit codes.
|
||||
# Exit codes are zero-based, so:
|
||||
# Exit Code 0 corresponds to Output 1
|
||||
# Exit Code 1 corresponds to Output 2
|
||||
# Exit Code 2 corresponds to Output 3
|
||||
# and so on. Exit codes outside the defined range will be treated as a failure output.
|
||||
|
||||
# Replace {file.FullName} and {file.Orig.FullName} with actual values
|
||||
WorkingFile=""{file.FullName}""
|
||||
OriginalFile=""{file.Orig.FullName}""
|
||||
|
||||
# Example commands using the variables
|
||||
echo ""Working on file: $WorkingFile""
|
||||
echo ""Original file location: $OriginalFile""
|
||||
|
||||
# Add your actual shell commands below
|
||||
# Example: Copy the working file to a backup location
|
||||
# cp ""$WorkingFile"" ""/path/to/backup/$(basename \""$WorkingFile\"")""
|
||||
|
||||
# Set the exit code to 0
|
||||
exit 0
|
||||
")]
|
||||
[Code(2, "sh")]
|
||||
public override string Code { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user