Refactored to take advantage of printw's printf capabilities.

This commit is contained in:
David Vereb 2019-03-29 18:35:22 -05:00
parent 1a012f519b
commit 8a103256df

View File

@ -6,16 +6,9 @@ int main(int argc, char *argv[])
{
initscr();
if(argc != 2)
{
printw("You must supply a filename as the only parameter.");
refresh();
getch();
endwin();
return 1;
}
std::string param = std::string(argv[1]);
std::string param = "-h"; // default to usage
if(argc == 2)
param = std::string(argv[1]);
if(param == "--help" || param == "-h")
{
printw("Supply the filename as the only parameter.\n");
@ -30,20 +23,17 @@ int main(int argc, char *argv[])
std::ifstream ifs(argv[1]);
if(!ifs.is_open())
{
printw("Permission Denied.");
printw("ERROR: File \"%s\" Not Found.", param.c_str());
refresh();
getch();
endwin();
return 2;
return 1;
}
noecho();
cbreak();
printw("New file, \"");
printw(argv[1]);
printw("\".\n");
printw("\n");
printw("New file, \"%s\".\n\n", param.c_str());
refresh();
getch();