dyaml/examples/resolver/main.d
Cameron Ross 7f913246ea Move custom types to Node (#213)
Move custom types to Node
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2019-01-15 08:37:50 +01:00

39 lines
745 B
D

import std.regex;
import std.stdio;
import dyaml;
int main(string[] args)
{
string path = "input.yaml";
if (args.length > 1)
{
path = args[1];
}
try
{
auto resolver = new Resolver;
resolver.addImplicitResolver("!color", regex("[0-9a-fA-F]{6}"),
"0123456789abcdefABCDEF");
auto loader = Loader.fromFile("input.yaml");
loader.resolver = resolver;
auto root = loader.load();
if(root["scalar-red"].tag == "!color" &&
root["scalar-orange"].tag == "!color")
{
writeln("SUCCESS");
return 0;
}
}
catch(YAMLException e)
{
writeln(e.msg);
}
writeln("FAILURE");
return 1;
}