feat(icon): icon.show handler + variadic positional schema (T-313)
icon.show resolves Phosphor glyphs by name (injected resolver) or a 0xNNNN
codepoint, reads a --file JSON array of {icon,label,description,color}
entries, validates colors via parseSvgColor (hex or CSS name), and
publishes on the `icon` bus channel. Honest userError on an unknown glyph,
a bad color, or a malformed payload. A trailing stringList positional is
now variadic so `icon show gear folder gauge` collects every token.
Flutter-free, dart-tested. Card widget + wiring next.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -156,8 +156,15 @@ class CommandSchema {
|
||||
final out = <String, Object?>{};
|
||||
final pos = raw['positional'];
|
||||
if (pos is List) {
|
||||
for (var i = 0; i < pos.length && i < positional.length; i++) {
|
||||
out[positional[i]] = pos[i];
|
||||
for (var i = 0; i < positional.length; i++) {
|
||||
final name = positional[i];
|
||||
// A trailing stringList positional is variadic: it absorbs ALL the
|
||||
// remaining tokens (e.g. `icon show gear folder gauge`), not just one.
|
||||
if (i == positional.length - 1 && args[name]?.type == ArgType.stringList) {
|
||||
out[name] = i < pos.length ? pos.sublist(i) : const <Object?>[];
|
||||
break;
|
||||
}
|
||||
if (i < pos.length) out[name] = pos[i];
|
||||
}
|
||||
}
|
||||
final flags = raw['flags'];
|
||||
|
||||
Reference in New Issue
Block a user