Skip to content

Commit 5589816

Browse files
committed
Improved help
1 parent 118a0fd commit 5589816

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

entries/ocoddo/src/Project1.lpr

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,8 @@ TStationSummary = record
365365
end;
366366

367367
function HandleParameters(out AFilePath: TFilePath): Bool;
368-
var
369-
I: Ind;
370-
N: Str;
371-
V: I64;
372-
begin
373-
Result := False;
374-
if Length(Parameters) = 0 then
368+
369+
procedure WriteHelp;
375370
begin
376371
WriteLn;
377372
WriteLn('1BRC');
@@ -386,14 +381,25 @@ TStationSummary = record
386381
WriteLn('--part-size=[Value]. Use 128, 192, 256, etc');
387382
WriteLn('--processor-count=[Value]. Use 1 or more');
388383
WriteLn;
384+
end;
385+
386+
var
387+
I: Ind;
388+
N: Str;
389+
V: I64;
390+
begin
391+
Result := False;
392+
if Length(Parameters) = 0 then
393+
begin
394+
WriteHelp;
389395
Exit;
390396
end;
391397

392398
ProcessorCount := LogicalProcessorCount;
393399
JumperCount := 256 * 1024;
394400
PartSize := 192 * 1024 - ReadMargin;
395401

396-
for I := 1 to High(Parameters) do
402+
for I := 0 to High(Parameters) do
397403
begin
398404
N := Name(Parameters[I]);
399405
ToI64(Value(Parameters[I]), V);
@@ -403,10 +409,20 @@ TStationSummary = record
403409
else if N = 'part-size' then
404410
PartSize := (V * 1024) - ReadMargin
405411
else if N = 'processor-count' then
406-
ProcessorCount := V;
412+
ProcessorCount := V
413+
else if N = 'help' then
414+
begin
415+
WriteHelp;
416+
Exit;
417+
end;
407418
end;
408419

409420
AFilePath := Fix(Value(Parameters[0]));
421+
if not Exists(FileSystemObject(AFilePath)) then
422+
begin
423+
WriteLn('File not found');
424+
Exit;
425+
end;
410426
Result := True;
411427
end;
412428

0 commit comments

Comments
 (0)