Skip to content

Commit 318a75e

Browse files
author
LoneWandererProductions
committed
sync back fixed weaver
1 parent 40eb107 commit 318a75e

35 files changed

Lines changed: 211 additions & 167 deletions

Weaver/CommandSignature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* COPYRIGHT: See COPYING in the top level directory
33
* PROJECT: Weaver;
44
* FILE: CommandSignature.cs
@@ -15,4 +15,4 @@ namespace Weaver
1515
/// <param name="Name">The name of the command.</param>
1616
/// <param name="ParameterCount">The number of parameters the command expects.</param>
1717
public record CommandSignature(string Namespace, string Name, int ParameterCount);
18-
}
18+
}

Weaver/Core/CommandExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ public sealed class CommandExtension
4646
/// </value>
4747
public bool IsPreview { get; init; }
4848
}
49-
}
49+
}

Weaver/Core/DeleteValueCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ public CommandResult Execute(params string[] args)
6666
public CommandResult InvokeExtension(string extensionName, params string[] args)
6767
=> CommandResult.Fail("'deleteValue' has no extensions.");
6868
}
69-
}
69+
}

Weaver/Core/EvaluateCommand.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class EvaluateCommand : ICommand
2929
public string Namespace => WeaverResources.GlobalNamespace;
3030

3131
/// <inheritdoc />
32-
public int ParameterCount => 1;
32+
public int ParameterCount => -1;
3333

3434
/// <inheritdoc />
3535
public CommandSignature Signature => new(Namespace, Name, ParameterCount);
@@ -58,13 +58,17 @@ public EvaluateCommand(IEvaluator evaluator, IVariableRegistry? registry = null)
5858
/// <inheritdoc />
5959
public CommandResult Execute(string[] args)
6060
{
61-
if (args.Length < 1)
62-
return CommandResult.Fail("evaluate() requires at least 1 argument: the expression to evaluate.");
61+
string? expression = args.Length > 0 ? args[0] : null;
62+
string? targetVar = args.Length > 1 ? args[1] : null;
6363

64-
var expression = args[0];
65-
var targetVar = args.Length > 1 ? args[1] : null;
64+
// If no expression, maybe store previous pipeline value or return null
65+
if (string.IsNullOrWhiteSpace(expression))
66+
{
67+
// Allow empty input if .store() will handle it
68+
return CommandResult.Ok(null);
69+
}
6670

67-
// Resolve variables from registry
71+
// Resolve variables from registry as before
6872
if (_registry != null)
6973
{
7074
foreach (var variable in _registry.GetAll())
@@ -81,7 +85,6 @@ public CommandResult Execute(string[] args)
8185
object? result;
8286
EnumTypes type;
8387

84-
// Detect if expression looks like boolean
8588
var isBooleanExpr = _evaluator.IsBooleanExpression(expression);
8689

8790
try
@@ -105,7 +108,7 @@ public CommandResult Execute(string[] args)
105108
);
106109
}
107110

108-
// Optional target variable storage
111+
// Store in registry if requested
109112
if (!string.IsNullOrWhiteSpace(targetVar))
110113
{
111114
if (_registry == null)
@@ -116,15 +119,15 @@ public CommandResult Execute(string[] args)
116119
);
117120
}
118121

119-
_registry.Set(targetVar, result, type);
122+
_registry.Set(targetVar, result!, type);
120123
return CommandResult.Ok(
121124
$"Stored '{result}' in '{targetVar}'.",
122125
result,
123126
type
124127
);
125128
}
126129

127-
// Return result
130+
// Return computed result
128131
var message = type switch
129132
{
130133
EnumTypes.Wbool => result?.ToString() ?? "false",
@@ -141,4 +144,4 @@ public CommandResult InvokeExtension(string extensionName, string[] args)
141144
return CommandResult.Fail($"'{Name}' has no extensions.");
142145
}
143146
}
144-
}
147+
}

Weaver/Core/GetValueCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ public CommandResult InvokeExtension(string extensionName, params string[] args)
8282
return CommandResult.Fail($"'{Name}' has no extensions.");
8383
}
8484
}
85-
}
85+
}

Weaver/Core/HelpCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ public CommandResult InvokeExtension(string extensionName, params string[] args)
8282
return CommandResult.Fail($"'{Name}' has no extensions.");
8383
}
8484
}
85-
}
85+
}

Weaver/Core/HelpExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public sealed class HelpExtension : ICommandExtension
2929
public int ExtensionParameterCount => 0;
3030

3131
/// <inheritdoc />
32-
public CommandResult Invoke(ICommand command, string[] args, Func<string[], CommandResult> executor)
32+
public CommandResult Invoke(ICommand command, string[] extensionArgs, Func<string[], CommandResult> executor, string[] commandArgs)
3333
{
3434
// Return description; executor not needed
3535
return CommandResult.Ok(command.Description);
3636
}
3737
}
38-
}
38+
}

Weaver/Core/ListCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ public CommandResult InvokeExtension(string extensionName, params string[] args)
7070
return CommandResult.Fail($"'{Name}' has no extensions.");
7171
}
7272
}
73-
}
73+
}

Weaver/Core/MemoryCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ public CommandResult InvokeExtension(string extensionName, params string[] args)
6363
return CommandResult.Fail($"'{Name}' has no extensions.");
6464
}
6565
}
66-
}
66+
}

Weaver/Core/PrintCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ public CommandResult InvokeExtension(string extensionName, params string[] args)
7474
return CommandResult.Fail($"'{Name}' has no extensions.");
7575
}
7676
}
77-
}
77+
}

0 commit comments

Comments
 (0)