Ignore:
Timestamp:
08/27/04 14:45:08 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/showlog.cc

    r4732 r4756  
    22#include <fstream>
    33
     4#include "MArgs.h"
     5
    46#include "MLog.h"
     7#include "MLogManip.h"
    58
    69using namespace std;
     
    1013    gLog << endl;
    1114    gLog << "Sorry the usage is:" << endl;
    12     gLog << "   showlog filename" << endl;
     15    gLog << "   showlog [options] filename" << endl;
    1316    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;
    1722    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;
    1826}
    1927
     
    2230int main(int argc, char **argv)
    2331{
    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)
    2551    {
    2652        Usage();
     
    2955
    3056    // casts necessary for gcc 2.95.3
    31     istream *in = argc==2 ? (istream*)new ifstream(argv[1]) : (istream*)&cin;
     57    istream *in = arg.GetNumArguments()==1 ? (istream*)new ifstream(arg.GetArgumentStr(0)) : (istream*)&cin;
    3258    if (!*in)
    3359    {
    34         gLog << "Cannot open file " << argv[1] << ": " << strerror(errno) << endl;
     60        gLog << "Cannot open file " << arg.GetArgumentStr(0) << ": " << strerror(errno) << endl;
    3561        return -1;
    3662    }
Note: See TracChangeset for help on using the changeset viewer.