Changeset 4756 for trunk/MagicSoft/Mars/showlog.cc
- Timestamp:
- 08/27/04 14:45:08 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/showlog.cc
r4732 r4756 2 2 #include <fstream> 3 3 4 #include "MArgs.h" 5 4 6 #include "MLog.h" 7 #include "MLogManip.h" 5 8 6 9 using namespace std; … … 10 13 gLog << endl; 11 14 gLog << "Sorry the usage is:" << endl; 12 gLog << " showlog filename" << endl;15 gLog << " showlog [options] filename" << endl; 13 16 gLog << " or" << endl; 14 gLog << " showlog < filename" << endl << endl; 15 gLog << " This program converts colored output made with ansi codes" << endl; 16 gLog << " (like it is done by MLog) and redirected into a file back" << endl; 17 gLog << " showlog [options] < filename" << endl << endl; 18 gLog << " -?, -h, --help This help" << endl << endl; 19 gLog << endl; 20 gLog << " This program converts colored output made with ansi codes" << endl; 21 gLog << " (like it is done by MLog) and redirected into a file back" << endl; 17 22 gLog << " into colored output." << endl << endl; 23 gLog << " It cannot be used to get rid of the Ansi codes. To display" << endl; 24 gLog << " colored output with less use the option -R, eg." << endl; 25 gLog << " less -R logfile.log" << endl << endl; 18 26 } 19 27 … … 22 30 int main(int argc, char **argv) 23 31 { 24 if (argc>2) 32 MArgs arg(argc, argv); 33 34 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help")) 35 { 36 Usage(); 37 return -1; 38 } 39 40 if (arg.GetNumOptions()>0) 41 { 42 gLog << warn << "WARNING - Unknown commandline options..." << endl; 43 arg.Print("options"); 44 gLog << endl; 45 } 46 47 // 48 // check for the right usage of the program 49 // 50 if (arg.GetNumArguments()>1) 25 51 { 26 52 Usage(); … … 29 55 30 56 // casts necessary for gcc 2.95.3 31 istream *in = arg c==2 ? (istream*)new ifstream(argv[1]) : (istream*)&cin;57 istream *in = arg.GetNumArguments()==1 ? (istream*)new ifstream(arg.GetArgumentStr(0)) : (istream*)&cin; 32 58 if (!*in) 33 59 { 34 gLog << "Cannot open file " << arg v[1]<< ": " << strerror(errno) << endl;60 gLog << "Cannot open file " << arg.GetArgumentStr(0) << ": " << strerror(errno) << endl; 35 61 return -1; 36 62 }
Note:
See TracChangeset
for help on using the changeset viewer.