11
11
// See the License for the specific language governing permissions and
12
12
// limitations under the License.
13
13
14
+ using Neuroglia ;
14
15
using ServerlessWorkflow . Sdk . Models . Processes ;
15
16
16
17
namespace ServerlessWorkflow . Sdk . Builders ;
@@ -42,6 +43,16 @@ public class ScriptProcessDefinitionBuilder
42
43
/// </summary>
43
44
public Uri ? SourceUri { get ; set ; }
44
45
46
+ /// <summary>
47
+ /// Gets the arguments, if any, of the command to execute
48
+ /// </summary>
49
+ protected virtual EquatableDictionary < string , object > ? Arguments { get ; set ; }
50
+
51
+ /// <summary>
52
+ /// Gets/sets the environment variables, if any, of the shell command to execute
53
+ /// </summary>
54
+ protected virtual EquatableDictionary < string , string > ? Environment { get ; set ; }
55
+
45
56
/// <inheritdoc/>
46
57
public virtual IScriptProcessDefinitionBuilder WithLanguage ( string language )
47
58
{
@@ -76,6 +87,40 @@ public virtual IScriptProcessDefinitionBuilder WithSource(Action<IExternalResour
76
87
return this ;
77
88
}
78
89
90
+ /// <inheritdoc/>
91
+ public virtual IScriptProcessDefinitionBuilder WithArgument ( string name , object value )
92
+ {
93
+ ArgumentException . ThrowIfNullOrWhiteSpace ( name ) ;
94
+ this . Arguments ??= [ ] ;
95
+ this . Arguments [ name ] = value ;
96
+ return this ;
97
+ }
98
+
99
+ /// <inheritdoc/>
100
+ public virtual IScriptProcessDefinitionBuilder WithArguments ( IDictionary < string , object > arguments )
101
+ {
102
+ ArgumentNullException . ThrowIfNull ( arguments ) ;
103
+ this . Arguments = new ( arguments ) ;
104
+ return this ;
105
+ }
106
+
107
+ /// <inheritdoc/>
108
+ public virtual IScriptProcessDefinitionBuilder WithEnvironment ( string name , string value )
109
+ {
110
+ ArgumentException . ThrowIfNullOrWhiteSpace ( name ) ;
111
+ this . Environment ??= [ ] ;
112
+ this . Environment [ name ] = value ;
113
+ return this ;
114
+ }
115
+
116
+ /// <inheritdoc/>
117
+ public virtual IScriptProcessDefinitionBuilder WithEnvironment ( IDictionary < string , string > environment )
118
+ {
119
+ ArgumentNullException . ThrowIfNull ( environment ) ;
120
+ this . Environment = new ( environment ) ;
121
+ return this ;
122
+ }
123
+
79
124
/// <inheritdoc/>
80
125
public override ScriptProcessDefinition Build ( )
81
126
{
@@ -85,6 +130,8 @@ public override ScriptProcessDefinition Build()
85
130
{
86
131
Language = this . Language ,
87
132
Code = this . Code ,
133
+ Arguments = this . Arguments ,
134
+ Environment = this . Environment
88
135
} ;
89
136
if ( this . Source != null ) process . Source = this . Source ;
90
137
else if ( this . SourceUri != null ) process . Source = new ( ) { Uri = this . SourceUri } ;
0 commit comments