postProcessDockerPs top-level property
Docker/Podman 容器处理函数
Implementation
final List<FigSuggestion> Function(String, [List<String>?])
postProcessDockerPs = (String out, [List<String>? tokens]) {
return out
.split('\n')
.where((line) => line.trim().isNotEmpty)
.map<FigSuggestion?>((line) {
try {
final parsedJSON = json.decode(line) as Map<String, dynamic>;
final name = parsedJSON['Names']?.toString() ?? '';
final image = parsedJSON['Image']?.toString() ?? '';
return FigSuggestion(
name: name,
displayName: '$name ($image)',
icon: 'fig://icon?type=docker',
);
} catch (error) {
print('Error parsing Docker container line: $error');
return null;
}
})
.where((suggestion) => suggestion != null)
.cast<FigSuggestion>()
.toList();
};