#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $session=$_{session};
	my $file=$_{quote};

	if ($file !~ /.+\.mooix/) {
		fail "Only files ending in \".mooix\" can be imported.";
	}

	if (! -f $file) {
		fail "Bad filename.";
	}

	open (IN, $file) || fail "Cannot read that file.";
	my @lines;
	while (<IN>) {
		chomp;
		push @lines, $_;
	}
	close IN;

	$this->data(@lines);
	my @ret=$this->check($this->parse(map {( line => $_ )} @lines));
	if (@ret) {
		$session->write($_) foreach @ret;
		fail "File imported, with warnings.";
	}
	
	$session->write("File imported.");
}
