예제 #1
0
int main(int argc, const char** argv)
{
	string inFile = "";
	string tileDir = "/class/cs225/mp6_bmps/";
	string numTilesStr = "100";
	string pixelsPerTileStr = "50";
	string outFile = "mosaic.png";

	OptionsParser optsparse;
	optsparse.addArg(inFile);
	optsparse.addArg(tileDir);
	optsparse.addArg(numTilesStr);
	optsparse.addArg(pixelsPerTileStr);
	optsparse.addArg(outFile);
	optsparse.addOption("help", opts::help);
	optsparse.addOption("h", opts::help);
	optsparse.parse(argc, argv);
	
	if (opts::help)
	{
		cout << "Usage: " << argv[0] << " background_image.png tile_directory/ [number of tiles] [pixels per tile] [output_image.png]" << endl;
		return 0;
	}

	if (inFile == "")
	{
		cout << "Usage: " << argv[0] << " background_image.png tile_directory/ [number of tiles] [pixels per tile] [output_image.png]" << endl;
		return 1;
	}

	makePhotoMosaic(inFile, tileDir, lexical_cast<int>(numTilesStr), lexical_cast<int>(pixelsPerTileStr), outFile);

    return 0;
}
예제 #2
0
파일: monad.cpp 프로젝트: erjohns3/CS_225
void monad::processArgs(int argc, const char* const* argv)
{
    // Create OptionsMap for options and vector for positional arguments:
    OptionsParser options;

    // Add our possible options to our map
    options.addOption("solution", opts::solution);
    options.addOption("newtests", opts::newtests);
    options.addOption("provided", opts::provided);
    options.addOption("clean", opts::clean);
    options.addOption("update", opts::update);
    options.addOption("staff", opts::staff);

    options.addOption("optimize", opts::optimize);
    options.addOption("detailed", opts::detailed);
    options.addOption("verbose", opts::verbose);
    options.addOption("buffer", opts::buffer);
    options.addOption("asan", opts::asan);
    options.addOption("parallel", opts::parallel);

    options.addOption("help", opts::help);
    options.addOption("h", opts::help);
    options.addOption("info", opts::info);
    options.addOption("version", opts::info);
    options.addOption("v", opts::info);
    options.addOption("license", opts::license);

    // Add arguments
    string assignment = "";
    options.addArg(assignment);

    // Read in options and arguments
    vector<string> posargs = options.parse(argc, argv);

    // Help
    if (opts::help || toLower(assignment) == "help")
    {
        if (toLower(assignment) == "config")
            printHelpConfig();
        else if (toLower(assignment) == "tests")
            printHelpTests();
        else
            printHelp();
        exit(0);
    }

    // Info
    if (opts::info)
    {
        printInfo();
        exit(0);
    }

    // License
    if (opts::license)
    {
        printLicense();
        exit(0);
    }

    // Clean
    if (toLower(assignment) == "clean")
    {
        system("/bin/rm -rf *_grade/ *_tests/ *_newtests/ *_provided/ "
               "*_solution/");
        exit(0);
    }

    // Check argument list length
    if (assignment == "")
    {
        cout << "Usage: " << argv[0] << " mp1" << endl;
        cout << "Run \'" << argv[0] << " --help\' for more information" << endl;
        exit(0);
    }

    // Find mp/lab name and tests folder
    if (assignment[assignment.length() - 1] == '/')
        assignment = assignment.substr(0, assignment.length() - 1);
    size_t slash_i = assignment.find_last_of('/');
    string assignment_name =
        (slash_i == string::npos) ? assignment : assignment.substr(slash_i + 1);
    string assignment_dir =
        (slash_i == string::npos) ? "" : assignment.substr(0, slash_i);

    // TODO (toole1): All this stuff is ugly!
    vector<string> splitname = tokenize(assignment_name, '.');
    assignment_base = splitname[0];
    if (splitname.size() == 1)
        mp_part = no_mp_part;
    else
        mp_part = lexical_cast<int>(splitname[1].c_str());

    gradeFolder = "./" + assignment_base + "_grade/";
    if (!exists(gradeFolder))
        opts::clean = true;

    if (opts::clean)
        tempFolder = "";
    else
        tempFolder = "./" + assignment_base + "_temp/";

    // Find source folder (i.e. ../mp1)
    // TODO (toole1): I'm not sure if we should really use updateFolder
    // vs getFolder here, and I've forgotten if the original reasoning
    // was deeper than I have the _solution in ../
    if (opts::solution)
        sourceFolder = updateFolder(assignment_base + "_solution/", false);
    else
        sourceFolder = getFolder(assignment_base + '/', assignment_dir, false);

    // tests folder
    if (opts::provided)
        testsFolder = updateFolder(assignment_base + "_provided/", false);
    else if (opts::newtests)
        testsFolder = updateFolder(assignment_base + "_newtests/", false);
    else
        testsFolder = updateFolder(assignment_base + "_tests/", false);
}
예제 #3
0
파일: monad.cpp 프로젝트: irtefa/dumbshit
void monad::processArgs(int argc, const char * const * argv)
{
    // Create OptionsMap for options and vector for positional arguments:
	OptionsParser options;

	// Add our possible options to our map
	options.addOption("solution", opts::solution);
	options.addOption("newtests", opts::newtests);
	options.addOption("provided", opts::provided);
	options.addOption("clean",    opts::clean);
	options.addOption("update",   opts::update);
	options.addOption("staff",    opts::staff);
	
	options.addOption("optimize", opts::optimize);
	options.addOption("verbose",  opts::verbose);
	options.addOption("buffer",   opts::buffer);
	options.addOption("valgrind", opts::valgrind);
	options.addOption("parallel", opts::parallel);

	options.addOption("help",     opts::help);
	options.addOption("h",        opts::help);
	options.addOption("info",     opts::info);
	options.addOption("version",  opts::info);
	options.addOption("v",        opts::info);
	options.addOption("license",  opts::license);

	// Add arguments
	string assignment = "";
	options.addArg(assignment);

	// Read in options and arguments
	vector<string> posargs = options.parse(argc, argv);
	
	// Help
	if (opts::help || toLower(assignment) == "help")
	{
		if (toLower(assignment) == "config")
			printHelpConfig();
		else if (toLower(assignment) == "tests")
			printHelpTests();
		else
			printHelp();
		exit(0);
	}

	// Info
	if (opts::info)
	{
		printInfo();
		exit(0);
	}
	
	// License
	if (opts::license)
	{
		printLicense();
		exit(0);
	}
	
	// Clean
	if (toLower(assignment) == "clean")
	{
		system("/bin/rm -rf *_grade/ *_tests/ *_newtests/ *_providedtests *_solution/");
		exit(0);
	}

	// Check argument list length
	if (assignment == "")
	{
		cout << "Usage: " << argv[0] << " mp1" << endl;
		cout << "Run \'" << argv[0] << " --help\' for more information" << endl;
		exit(0);
	}

	// Find mp/lab name and tests folder
	vector<string> splitname = tokenize(assignment, '.');
	assignment_base = splitname[0];
	if (splitname.size() == 1)
		mp_part = no_mp_part;
	else
		mp_part = lexical_cast<int>(splitname[1].c_str());
	
	gradeFolder = "./" + assignment_base + "_grade/";
	if (!exists(gradeFolder)) opts::clean = true;

	if (opts::clean)
		tempFolder = "";
	else
		tempFolder  = "./" + assignment_base + "_temp/";

	// Find source folder (i.e. ../mp1)
	if (opts::solution)
		sourceFolder = updateFolder(assignment_base + "_solution/", false);
	else
		sourceFolder = getFolder(assignment_base + '/', false);

	// tests folder
	if (opts::provided)
		testsFolder = updateFolder(assignment_base + "_provided/", false);
	else if (opts::newtests)
		testsFolder = updateFolder(assignment_base + "_newtests/", false);
	else
		testsFolder = updateFolder(assignment_base + "_tests/", false);
}