usermnSdcSpec top-level property
Implementation
final usermnSdcSpec = FigSpec(
name: "sdc",
generateSpec:
(List<String> tokens, ExecuteCommandFunction executeCommand) async {
try {
final out = await executeCommand(ExecuteCommandInput(
command: "npx",
args: ["@usermn/sdc", "--version"],
));
final version = out.stdout.trim();
// Start with base spec options
final currentOptions = List<FigOption>.from(baseSpec.options ?? []);
// Sort versions ascending
final sortedVersions = versionDiffs.keys.toList()
..sort((a, b) => _versionGte(a, b) ? 1 : -1);
for (final v in sortedVersions) {
// If current version >= diff version, apply diff
if (_versionGte(version, v)) {
final diff = versionDiffs[v];
if (diff?.options != null) {
currentOptions.addAll(diff!.options!);
}
}
}
return FigSpec(
name: "sdc",
description: baseSpec.description,
subcommands: baseSpec.subcommands,
options: currentOptions,
args: baseSpec.args,
);
} catch (e) {
return _createSpecFromSubcommand(baseSpec);
}
},
);