getShellBlock function
get scripts input from yaml
Implementation
Map<String, List<String>> getShellBlock(
Config config,
Map<String, String> env,
String workdir, [
List<String> blocks = const [],
]) {
final String os_ = config.optionalString('os') ?? '';
if (!isOsMatched(os_)) throw UsageException('err: invalid os', '');
final map = <String, List<String>>{}; // map blockname, scripts;
if (blocks.isEmpty) blocks.add('scripts');
for (var blockName in blocks) {
var cmds = config.optionalStringList(blockName);
if (cmds == null || cmds.isEmpty) {
throw UsageException('err: required $blockName list', '');
}
// final lpm = LocalProcessManager();
for (var cmd in cmds) {
final undef = undefined(cmd, env);
if (undef.isNotEmpty) {
throw UsageException('err: undef $undef, $cmd', '');
}
// final canrun = lpm.canRun(name, workingDirectory: workdir);
// if (!canrun) throw UsageException('err: can not run, $value', '');
}
map[blockName] = cmds;
}
return map;
}