#include <ast/statements/ContainerFileStatement.h>
#include <ast/Statement.h>
#include <ast/Option.h>
#include <ast/Arg.h>
#include <abstraction/Registry.h>

namespace cli {

ContainerFileStatement::ContainerFileStatement ( std::string container, ext::vector < std::unique_ptr < Option > > options, std::unique_ptr < Arg > file ) : m_file ( std::move ( file ) ), m_container ( std::move ( container ) ), m_options ( std::move ( options ) ) {
	for ( const std::unique_ptr < Option > & option : m_options ) {
		option->eval ( * this );
	}
}

std::shared_ptr < abstraction::OperationAbstraction > ContainerFileStatement::translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > &, Environment & environment ) const {
	return abstraction::Registry::getContainerAbstraction ( m_container, m_type, m_file->eval ( environment ) );
}

void ContainerFileStatement::setType ( std::string type ) {
	m_type = std::move ( type );
}

} /* namespace cli */