- Timestamp:
- Jul 28, 2015, 1:54:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/linetime.lpr
r3 r4 26 26 LogFile: TFileStream; 27 27 LogEnabled: Boolean; 28 TermString: string; 29 TermStringIndex: Integer; 28 30 procedure WriteRaw(Text: string); 29 31 procedure WriteLog(Text: string); … … 49 51 begin 50 52 // Quick check parameters 51 ErrorMsg := CheckOptions('hcl ', 'help csv log');53 ErrorMsg := CheckOptions('hclt:', 'help csv log termstr'); 52 54 if ErrorMsg <> '' then begin 53 55 ShowException(Exception.Create(ErrorMsg)); … … 62 64 Exit; 63 65 end; 66 67 if HasOption('t', 'termstr') then begin 68 TermString := GetOptionValue('t', 'termstr'); 69 end else TermString := ''; 64 70 65 71 FormatCSV := HasOption('c', 'csv'); … … 77 83 StartTime := Now; 78 84 LastLineTime := 0; 85 TermStringIndex := 1; 79 86 try 80 87 InputStream := TIOStream.Create(iosInput); … … 84 91 SetLength(Buffer, Count); 85 92 ProcessBuffer(Buffer); 86 until Count = 0; 87 93 until (Count = 0) or Terminated; 88 94 PrintOutput(''); 89 95 finally … … 93 99 WriteLog(LineEnding); 94 100 95 // stop program loop96 101 Terminate; 97 102 end; … … 145 150 var 146 151 P: Integer; 152 I: Integer; 147 153 Part: string; 148 154 begin … … 158 164 ShowTime := True; 159 165 end; 166 167 // Search for termination string 168 if TermString <> '' then 169 for I := 1 to Length(Buffer) - 1 do begin 170 if TermStringIndex > Length(TermString) then begin 171 Terminate; 172 Break; 173 end; 174 if Buffer[I] = TermString[TermStringIndex] then 175 Inc(TermStringIndex) 176 else TermStringIndex := 1; 177 end; 160 178 until P = 0; 161 179 PrintOutput(Buffer); … … 178 196 { add your help code here } 179 197 WriteLn('Usage: ', ExeName, ' -h'); 180 WriteLn(' -c --csv Print lines in CSV format'); 181 WriteLn(' -l --log Log output to log files in ~/.linetime/logs'); 198 WriteLn(' -c --csv Print lines in CSV format'); 199 WriteLn(' -l --log Log output to log files in ~/.linetime/logs'); 200 WriteLn(' -t --termstr <string> Termination string'); 182 201 end; 183 202
Note:
See TracChangeset
for help on using the changeset viewer.