Skip to content
Snippets Groups Projects
Commit 37d9cab5 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Made it so help message is output for bad input to simplemd. closes #40

parent 2ff611f3
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ keys(k) ...@@ -38,7 +38,7 @@ keys(k)
} }
void CLTool::registerKeywords( Keywords& keys ){ void CLTool::registerKeywords( Keywords& keys ){
keys.addFlag("--help",false,"print this help"); keys.addFlag("--help/-h",false,"print this help");
} }
CLTool::CLTool(const CLToolOptions& co ): CLTool::CLTool(const CLToolOptions& co ):
...@@ -106,6 +106,9 @@ bool CLTool::readCommandLineArgs( int argc, char**argv, FILE*out ){ ...@@ -106,6 +106,9 @@ bool CLTool::readCommandLineArgs( int argc, char**argv, FILE*out ){
} }
if(!found){ if(!found){
fprintf(stderr,"ERROR in input for command line tool %s : %s option is unknown \n\n", name.c_str(), a.c_str() ); fprintf(stderr,"ERROR in input for command line tool %s : %s option is unknown \n\n", name.c_str(), a.c_str() );
fprintf(out,"Usage: %s < inputFile \n", name.c_str() );
fprintf(out,"inputFile should contain one directive per line. The directives should come from amongst the following\n\n");
keywords.print( out );
printhelp=true; printhelp=true;
} }
} }
...@@ -160,7 +163,10 @@ bool CLTool::readInputFile( int argc, char**argv, FILE* in, FILE*out ){ ...@@ -160,7 +163,10 @@ bool CLTool::readInputFile( int argc, char**argv, FILE* in, FILE*out ){
if(argc==2){ if(argc==2){
mystdin=fopen(argv[1],"r"); mystdin=fopen(argv[1],"r");
if(!mystdin){ if(!mystdin){
fprintf(stderr,"ERROR: cannot open file %s\n",argv[1]); fprintf(stderr,"ERROR: cannot open file %s\n\n",argv[1]);
fprintf(out,"Usage: %s < inputFile \n", name.c_str() );
fprintf(out,"inputFile should contain one directive per line. The directives should come from amongst the following\n\n");
keywords.print( out );
return false; return false;
} }
} }
...@@ -183,7 +189,10 @@ bool CLTool::readInputFile( int argc, char**argv, FILE* in, FILE*out ){ ...@@ -183,7 +189,10 @@ bool CLTool::readInputFile( int argc, char**argv, FILE* in, FILE*out ){
} }
} }
if(!found){ if(!found){
fprintf(stderr,"ERROR in input for command line tool %s : unknown keyword %s found in input file\n",name.c_str(),keyword.c_str()); fprintf(stderr,"ERROR in input for command line tool %s : unknown keyword %s found in input file\n\n",name.c_str(),keyword.c_str());
fprintf(out,"Usage: %s < inputFile \n", name.c_str() );
fprintf(out,"inputFile should contain one directive per line. The directives should come from amongst the following\n\n");
keywords.print( out );
if(mystdin) fclose(mystdin); if(mystdin) fclose(mystdin);
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment