Switched to printf, changed to using a function to check if any arguments are empty
This commit is contained in:
parent
8e3d1557a8
commit
a33833875c
1 changed files with 13 additions and 5 deletions
18
Src/blog.cpp
18
Src/blog.cpp
|
@ -34,10 +34,8 @@ std::string getArgValue(int argc, char* argv[], std::string argIdString)
|
|||
if (strncmp(argId, argv[i], idValSplit) == 0)
|
||||
return std::string(argv[i]).substr(idValSplit+1, strlen(argv[i])-(idValSplit+1));
|
||||
}
|
||||
|
||||
std::cout << "Missing argument!"; //the program exists if the value is 0
|
||||
std::cout << argIdString;
|
||||
exit(0);
|
||||
printf("Missing argument! %s", argIdString); //the program exists if the value is 0
|
||||
return std::string("")
|
||||
}
|
||||
|
||||
bool doesArgExist(int argc, char* argv[], std::string argIdString)
|
||||
|
@ -57,6 +55,15 @@ void copyFolderAndContents(std::string inUrl, std::string outUrl)
|
|||
std::filesystem::copy(inUrl, outUrl, opts);
|
||||
}
|
||||
|
||||
void checkForEmptyArguments()
|
||||
{
|
||||
// I hate doing it like this
|
||||
if (source.empty() || output.empty() || stat.empty() || siteWebUrl.empty() || blogTemplate.empty() || atomTemplate.empty())
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -in="" // give source folder
|
||||
* -out="" // give output folder
|
||||
|
@ -72,6 +79,7 @@ int main(int argc, char* argv[])
|
|||
std::string blogTemplate = getArgValue(argc, argv, "-blogTemplate=");
|
||||
std::string atomTemplate = getArgValue(argc, argv, "-atomTemplate=");
|
||||
|
||||
checkForEmptyArguments()
|
||||
|
||||
int flags = OptionFlags::NONE;
|
||||
if (doesArgExist(argc, argv, "-hide"))
|
||||
|
@ -82,7 +90,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// pre-written pages and resources i.e. images
|
||||
copyFolderAndContents(stat, output);
|
||||
std::cout << "Enjoy your website :)";
|
||||
printf("Enjoy your website :)");
|
||||
}
|
||||
|
||||
// TODO: nav sections :eww:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue