halkyon/apps/meditate/halkyon_meditate_server/bin/check_library.dart

29 lines
1,013 B
Dart
Raw Normal View History

import 'dart:io';
import 'package:halkyon_meditate_server/src/library/library_manifest.dart';
/// Checks an operator's library folder before it is deployed (ADR 0038,
/// D16), as the server reads it: what it would serve, and every item,
/// course and category it would refuse, with the reason. Exits 1 where
/// anything is refused, 64 without a folder.
///
/// dart run bin/check_library.dart /srv/meditate-library
void main(List<String> args) {
if (args.length != 1) {
stderr.writeln('Usage: dart run bin/check_library.dart <library folder>');
exitCode = 64;
return;
}
final library = readLibrary(Directory(args.single));
for (final problem in library.problems) {
stdout.writeln('✗ $problem');
}
stdout.writeln(
'${library.items.length} items, ${library.courses.length} courses and '
'${library.categories.length} categories of its own would be served; '
'${library.problems.length} problems.',
);
if (library.problems.isNotEmpty) {
exitCode = 1;
}
}