コード例 #1
0
ファイル: programSetUp.hpp プロジェクト: umass-bib/bibcpp
	/**@brief A function to start a runLog in the named directory
	 * @param dirName The name of the directory to start the runLog, runLog name
	 *will be runLog_[NAME_OF_PROGRAM]
	 *
	 */
	void startARunLog(const std::string &dirName) {
		rLog_.setFilenameAndOpen(
				files::make_path(dirName,"runLog_"
						+ replaceString(replaceString(commands_.getProgramName(), "./", ""),
								" ", "-")+ "_" + getCurrentDate() + ".txt").string(), timer_.start_);
		rLog_.startRunLog(commands_);
	}
コード例 #2
0
ファイル: programSetUp.hpp プロジェクト: umass-bib/bibcpp
	bool setOption(T &option, std::string flagStr,
			const std::string & shortDescription, bool required,
			const std::string & flagGrouping) {
		bool found = false;
		try {
			Flag currentFlag(option, flagStr, shortDescription, required, flagGrouping);
			std::vector<std::string> flagsFound;
			for (const auto &fTok : currentFlag.flags_) {
				if (commands_.lookForOptionDashCaseInsen(option, fTok)) {
					currentFlag.setValue(option);
					found = true;
					flagsFound.emplace_back(fTok);
				}
			}

			if (required && !found) {
				std::stringstream tempStream;
				tempStream << bashCT::bold + bashCT::black << "Need to have "
						<< bashCT::red << conToStr(tokenizeString(flagStr, ","), " or ")
						<< bashCT::black << " see " << bashCT::red
						<< commands_.getProgramName() + " --help " << bashCT::black
						<< "for more details" << bashCT::reset;
				warnings_.emplace_back(tempStream.str());
				failed_ = true;
			}
			if (found && flagsFound.size() > 1) {
				std::stringstream tempStream;
				tempStream << "Found multiple flags for the same option, found "
						<< conToStr(flagsFound, ", ") << " but should only have one";
				warnings_.emplace_back(tempStream.str());
				failed_ = true;
			}
			flags_.addFlag(currentFlag);
		} catch (std::exception & e) {
			std::stringstream ss;
			ss << "Error setting option for " << flagStr << "\n";
			ss << "Exception: " << e.what() << "\n";
			throw std::runtime_error{ss.str()};
		}
		return found;
	}
コード例 #3
0
ファイル: programSetUp.hpp プロジェクト: umass-bib/bibcpp
	/**@brief Get a string formated run time in seconds rounded to the nearest
	 * hundreth
	 * @return A string wiht run time formated to tell time for hrs, minutes,
	 * seconds etc.
	 */
	std::string getRunTime() {
		return commands_.getProgramName() + " (" + timer_.totalTimeFormatted(2) + ")";
	}