You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dateKeys-dart/tool/age_interop_dart_samples.dart

36 lines
1.3 KiB

// Writes the samples of the interoperability of the age writer of
// datekeys-dart, stage 6a: the age files of the recipes of
// test/age_interop_support.dart, which this library writes with
// SeededRandomSource, and samples.json, the recipes with the name of each
// file, into a directory. tool/age_interop_go_verdicts.go then opens them
// with Go and writes test/vectors/age_interop.json; the tests write the
// files again from the recipes and compare them with what Go read.
//
// dart run tool/age_interop_dart_samples.dart <directory>
//
// ignore_for_file: avoid_print
import 'dart:convert';
import 'dart:io';
import '../test/age_interop_support.dart';
void main(List<String> args) {
if (args.length != 1) {
stderr.writeln('usage: dart run tool/age_interop_dart_samples.dart <dir>');
exit(2);
}
final dir = Directory(args.single)..createSync(recursive: true);
final samples = interopSamples();
for (var i = 0; i < samples.length; i++) {
final s = samples[i];
final name = '$i.age';
File('${dir.path}/$name').writeAsBytesSync(writeSample(s));
s['file'] = name;
print('${s['name']}: $name');
}
File('${dir.path}/samples.json').writeAsStringSync(
const JsonEncoder.withIndent(' ').convert({'samples': samples}),
);
print('wrote ${samples.length} samples to ${dir.path}');
}

Powered by TurnKey Linux.