public static void main(String[] args) throws Throwable {

		// Checks if the correct number of arguments are provided.
		// Terminate if false.
		try {
			//Case 1: When user has provided:
			//		  1. Path to the target image.
			//        2. Path to the tile images directory.
			if (args.length == 2) {

				new Main().validateFilePath(args[0], IMAGE_EXTS);

				new Main().validateFolderPath(args[1], IMAGE_EXTS);

				new Main().validateTileDimension(Main.getTARGET_IMG_DIR(), Main
						.getTILE_IMG_DIR());

				setOUTPUT_IMG_DIR(genOutputFilename(args[0]));

				Main.setREUSE_LIMIT(100000);

				GenerateTileOutput.GenerateOutput();

			} 
			//Case 2: When user has provided:
			//		  1. Path to the target image.
			//        2. Path to the tile images directory.
			//        3. Path to the output image
			else if (args.length == 4 && args[2].equals("-o")) {

				new Main().validateFilePath(args[0], IMAGE_EXTS);

				new Main().validateFolderPath(args[1], IMAGE_EXTS);

				new Main().validateTileDimension(Main.getTARGET_IMG_DIR(), Main
						.getTILE_IMG_DIR());

				new Main().validateOutputPath(args[3], IMAGE_EXTS);

				Main.setREUSE_LIMIT(1000000);

				GenerateTileOutput.GenerateOutput();

			} 
			//Case 3: When user has provided:
			//		  1. Path to the target image.
			//        2. Path to the tile images directory.
			//        3. Reuse limit for a single tile image.
			else if (args.length == 4 && args[2].equals("-r")) {

				new Main().validateFilePath(args[0], IMAGE_EXTS);

				new Main().validateFolderPath(args[1], IMAGE_EXTS);

				new Main().validateTileDimension(Main.getTARGET_IMG_DIR(), Main
						.getTILE_IMG_DIR());

				new Main().validateRepeat(Integer.parseInt(args[3]));

				Main.setOUTPUT_IMG_DIR(genOutputFilename(args[0]));

				GenerateTileOutput.GenerateOutput();

			} 
			//Case 4: When user has provided:
			//		  1. Path to the target image.
			//        2. Path to the tile images directory.
			//        3. Path to the output image.
			//        4. Reuse limit for a single tile image.
			else if (args.length == 6 && args[2].equals("-o")
					&& args[4].equals("-r")) {

				new Main().validateFilePath(args[0], IMAGE_EXTS);

				new Main().validateFolderPath(args[1], IMAGE_EXTS);

				new Main().validateTileDimension(Main.getTARGET_IMG_DIR(), Main
						.getTILE_IMG_DIR());

				new Main().validateOutputPath(args[3], IMAGE_EXTS);

				new Main().validateRepeat(Integer.parseInt(args[5]));

				GenerateTileOutput.GenerateOutput();

			} 
			// For any other combination of invalid arguments
			// the program will report an error to the user
			// and will exit.
			else {
				System.err
						.println("Invalid input arguments.Please read the README file.");
				System.exit(0);
			}

		} catch (NumberFormatException e) {
			System.out
					.println("Repeat count parameter should be an unsigned integer value");
			System.exit(0);
		}

	}