#!/usr/bin/env raku
use v6.d;

use Data::Translators;
use JSON::Fast;

my %*SUB-MAIN-OPTS = :named-anywhere;

#| Convert data into another format.
multi sub MAIN(
        Str $data,                #= Data to convert.
        Str :t(:$target) = 'HTML', #= Target to convert to, one of <JSON HTML R>.
        Bool :$encode = False,    #= Whether to encode or not.
        Bool :$escape = False,    #= Whether to escape or not.
        Str :$field-names = '',   #= Field names to use for Map objects, separated with ';'.
               ) {

    my @fieldNames = $field-names ?? $field-names.split(';') !! [];
    say data-translation($data, :$target, :$encode, :$escape, field-names => @fieldNames);
}
