#! /usr/bin/env perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../lib";

use constant DISTRIBUTION => 'CXC-Optics-Prescription-LVS';

use CXC::Optics::Prescription::LVS::Mirror;

use Path::Tiny;

use YAML qw[ DumpFile ];

use Getopt::Long::Descriptive;

my ( $opt, $usage ) = describe_options(
    "$0 %o",
    [ 'input=s',  'mirror output file',           { required     => 1 } ],
    [ 'output=s', 'yaml output file',             { required     => 1 } ],
    [ 'help',     "print usage message and exit", { shortcircuit => 1 } ] );

print( $usage->text ), exit if $opt->help;

my $sharedir = path( path( $FindBin::Bin )->parent, 'share', 'mirror' );
$sharedir->mkpath;
my $output = $sharedir->child( $opt->output . '.yaml' );

DumpFile( $output,
    CXC::Optics::Prescription::LVS::Mirror->parse_mirror_output( $opt->input )
);
