Clarify script mutation limits

This commit is contained in:
Joseph Doherty
2026-05-05 16:40:55 -04:00
parent c12fbc5988
commit 87c0124174
7 changed files with 76 additions and 21 deletions
@@ -426,7 +426,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.Commands
public override Dictionary<string, object> Args() { var args = base.Args(); args["script"] = Script; return args; }
}
[Command("object scripts set", Description = "Set an object script body when supported by the local adapter")]
[Command("object scripts set", Description = "Attempt to set object script text through GRAccess; package-only ScriptExtension text fails fast")]
public sealed class ObjectScriptsSetCommand : ObjectScriptsGetCommand
{
public override string Subcommand => "scripts-set";
@@ -434,7 +434,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.Commands
[CommandOption("file", Description = "Script source file", IsRequired = true)]
public string File { get; init; }
[CommandOption("field", Description = "Script-text field to write: ExecuteText (default), DeclarationsText, StartupText, ShutdownText, OnScanText, OffScanText, Expression. Pass to target a non-body field; omit to default to ExecuteText.")]
[CommandOption("field", Description = "Script-text field to write: ExecuteText (default), DeclarationsText, StartupText, ShutdownText, OnScanText, OffScanText, Expression. Package-only fields fail fast instead of silently no-oping.")]
public string Field { get; init; } = "";
public override Dictionary<string, object> Args() { var args = base.Args(); args["file"] = File; args["field"] = Field; return args; }
@@ -454,7 +454,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.Commands
[CommandOption("trigger-type", Description = "Script trigger type value")]
public string TriggerType { get; init; } = "";
[CommandOption("expression", Description = "Script expression value")]
[CommandOption("expression", Description = "Script expression text. On local ScriptExtension builds this is package-only and fails fast.")]
public string Expression { get; init; } = "";
[CommandOption("lock-trigger-period", Description = "Lock TriggerPeriod in this object after setting it")]
@@ -475,7 +475,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.Commands
}
}
[Command("object scripts create", Description = "Create a ScriptExtension primitive and optionally initialize its body/settings")]
[Command("object scripts create", Description = "Create a ScriptExtension primitive and optionally initialize mutable settings")]
public sealed class ObjectScriptsCreateCommand : ObjectScriptSettingsCommandBase
{
public override string Subcommand => "scripts-create";
@@ -486,7 +486,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.Commands
public override Dictionary<string, object> Args() { var args = base.Args(); args["file"] = File; return args; }
}
[Command("object scripts settings set", Description = "Set ScriptExtension settings through ConfigurableAttributes")]
[Command("object scripts settings set", Description = "Set mutable ScriptExtension settings through ConfigurableAttributes")]
public sealed class ObjectScriptsSettingsSetCommand : ObjectScriptSettingsCommandBase
{
public override string Subcommand => "scripts-settings-set";
@@ -143,6 +143,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.GRAccess
RequireConfirm(args, Arg(args, "name"));
return AtomicObjectEdit(FindSingleObject(galaxy, Kind(args), Arg(args, "name")), obj => ObjectScriptCreate(galaxy, obj, args));
case "scripts-delete":
RequireConfirm(args, Arg(args, "name"));
return AtomicObjectEdit(FindSingleObject(galaxy, Kind(args), Arg(args, "name")), obj =>
{
var scriptName = Arg(args, "script");
@@ -1693,6 +1694,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.GRAccess
if (!string.IsNullOrWhiteSpace(triggerPeriodMs))
{
var attr = FindAttributeForMutation(obj, scriptName + ".TriggerPeriod");
EnsureMutableViaSetValue(attr, scriptName + ".TriggerPeriod");
attr.SetValue(CreateMxValue(triggerPeriodMs, "elapsed-ms"));
yield return CommandSummary(attr, $"Set script {scriptName}.TriggerPeriod");
@@ -1707,6 +1709,7 @@ namespace ZB.MOM.WW.GRAccess.Cli.GRAccess
if (!string.IsNullOrWhiteSpace(triggerType))
{
var attr = FindAttributeForMutation(obj, scriptName + ".TriggerType");
EnsureMutableViaSetValue(attr, scriptName + ".TriggerType");
attr.SetValue(CreateMxValue(triggerType, "string"));
yield return CommandSummary(attr, $"Set script {scriptName}.TriggerType");