Пример #1
0
	bool LibConfigProgram::parseCommandLine(int argc, char** argv)
	{
		// The Command line parser
		GetOpt::Parser opts;

		// Compiler
		opts.addParagraph("\nTypical usage example :\n  $ yuni-config -c gcc -m script --cxxflags\n\nCompiler settings:");
		opts.addFlag(pOptCxxFlags, ' ', "cxxflags", "Print the CXX flags (*)");
		opts.addFlag(pOptLibFlags, ' ', "libs", "Print the Libs flags (*)");
		opts.add(pOptCompiler, 'c', "compiler", "Set the target compiler (gcc,msvc,mingw,icc,...)");
		opts.addFlag(pOptPrintCompilerByDefault, ' ', "compiler-default", "Print the compiler used by default and exit");

		// All required modules
		opts.addParagraph("\nModules:");
		opts.add(pOptModules, 'm', "modules", "Add one or several requested modules (*)");
		opts.addFlag(pOptModuleList, ' ', "module-list", "Print all available modules of the selected version and exit (*)");
		opts.addFlag(pOptPrintModulesDeps, ' ', "module-deps", "Print all modules and the dependencies required and exit (*)");

		// Prefix
		opts.addParagraph("\nSearching paths:");
		opts.add(pOptPrefix, 'p', "prefix", "Add a prefix folder for searching available versions of libyuni");
		opts.addFlag(pOptNoDefaultPath, ' ', "no-default-path", "Do not use the default paths to find available versions of libyuni");
		opts.addFlag(pOptDefaultPathList, ' ', "default-path-list", "Print the default paths that would be used and exit (empty if 'no-default-path' is enabled)");

		opts.addParagraph("\nVersions:");
		opts.addFlag(pOptList, 'l', "list", "Print the list of all versions of libyuni which have been found (with complete informations) and exit");
		opts.addFlag(pOptListOnlyVersions, ' ', "list-only-versions", "Print the list of all versions of libyuni which have been found and exit");

		// Help
		opts.addParagraph("\nHelp\n  * : Option related to the selected version of libyuni");
		bool quiet = false;
		opts.addFlag(quiet, ' ', "quiet", "Suppress error messages");
		opts.addFlag(pOptDebug, ' ', "debug", "Print debug messages");
		opts.addFlag(pOptVersion, 'v', "version", "Print the version and exit");

		if (!opts(argc, argv))
		{
			pExitStatus = opts.errors() ? 1 /*error*/ : 0;
			if ((pOptPrintErrors and not quiet) || pOptDebug)
				std::cout << "Error when parsing the command line\n";
			return false;
		}

		if (quiet)
			pOptPrintErrors = false;

		if (pOptPrintCompilerByDefault)
		{
			std::cout << YUNI_LIBCONFIG_DEFAULT_COMPILER << "\n";
			return false;
		}

		// Clean the prefix paths (make them absolute)
		pVersionList.debug(pOptDebug);
		cleanPrefixPaths();
		normalizeCompiler();

		return true;
	}
Пример #2
0
int main(int argc, char* argv[])
{
	LoggingFacility logs;

	bool doAskModifyDate(false);

	GetOpt::Parser parser;
	String parameterFile;
	parser.addParagraph("\nUsual option(s):\n");
	parser.add(parameterFile, ' ', "parameter_file", "Parameters file. If not precised "
		"parameters.ini in current folder is attempted.");
	parser.addParagraph("\nVery seldom and specific option(s):\n");
	AnyString description("If this flag is present, ask whenever a new folder is scanner for"
		" new photos whether a date is to be manually entered; if so the exif of the pictures "
		" inside that directory will be modified if the date doesn't match the date already there. "
		"This is useful for instance when applying the program to photos which exif date are "
		"uncertain but date are known are known otherwise.");
	parser.addFlag(doAskModifyDate, ' ', "do_ask_modify_date", description);
	parser.addParagraph("\nHelp:\n");

	if (!parser(argc, argv))
		exit(EXIT_FAILURE);

	// Default values
	if (parameterFile.empty())
		parameterFile = "parameters.ini";


	try
	{
		typedef GenericTools::ReadParameterFile::KeyString KeyString;
		std::list<KeyString> keys;
		keys.push_back("inputFolder");
		keys.push_back("outputFolder");
		keys.push_back("pathFormat");
		keys.push_back("logFile");

		GenericTools::SqliteWrapper db("test.db3", SQLITE_OPEN_READWRITE);

		ExtendedPhoto::Cameras cameras(db);

		const GenericTools::ReadParameterFile parameters(logs, parameterFile, keys);
		PhotoDirectory::PhotoDirectory photoDirectory(logs, cameras, parameters["outputFolder"], parameters["pathFormat"]);
		SortNewPhotos::SortNewPhotos sortNewPhotos(logs, cameras, parameters["inputFolder"], photoDirectory,
			parameters["logFile"], doAskModifyDate);

		if (!sortNewPhotos.proceed())
			return EXIT_FAILURE; 
	}
	catch(const std::exception& e)
	{
		std::cout << "EXCEPTION: " << e.what() << '\n';
		exit(EXIT_FAILURE);
	}

	return 0;
}