package main;

import java.util.ArrayList;

import data.DataBase;
import data.DataParser;
import data.Movie;
import logic.Recomendations;

public class Main {

	Recomendations rec = new Recomendations();
	
	public static void main(String[] args) {
		new Main().start(args);
	}
	
	public void start(String[] args) {
		new DataParser();
		if(args != null) {
			for(String s : args) {
				switch(s.substring(0,s.indexOf("="))) {
				case "--test":
					break;
				case "--genre":
					for(Movie m : rec.withGenre(s.substring(s.indexOf("=")+1).replaceAll("'", ""), 20)) {
						System.out.println(m);
					}
					break;
				case "--actor":
					//DataBase.getInstance().printMovies();
					for(Movie m : rec.withActor(DataBase.getInstance().getActorByName(s.substring(s.indexOf("=")+1).replaceAll("'", "")), 20)) {
						System.out.println(m);
					}
					break;
				case "--director":
					for(Movie m : rec.withDirector((DataBase.getInstance().getDirectorByName(s.substring(s.indexOf("=")+1).replaceAll("'", ""))), 20)) {
						System.out.println(m);
					}
					break;
				case "--film":
					for(Movie m : rec.likedByUserWhoLike(DataBase.getInstance().getMovieByName(s.substring(s.indexOf("=")+1).replaceAll("'", "").trim()), 20)) {
						System.out.println(m);
					}
					break;
				case "--limit":
					break;
				case "--printdb":
					System.out.println("printing db");
					//new DataParser();
					
					DataBase.getInstance().printMovies();
					break;
				default:
					System.out.println("argument "+s+" is unkown");
				}
			}
		}else {
			new ConsoleReader();
		}
	}
	
	private void printList(ArrayList<Object> list) {
		for(Object o : list) {
			System.out.println(o);
		}
	}
	
}
