mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-10 07:48:21 +01:00
* Emit help text if options not correct
git-svn-id: trunk@11370 -
This commit is contained in:
parent
0eb08af40e
commit
32d0e652ff
@ -25,17 +25,31 @@ program chmcmd;
|
||||
uses
|
||||
Classes, chmfilewriter;
|
||||
|
||||
Procedure Usage;
|
||||
|
||||
begin
|
||||
Writeln(StdErr,'Usage: chmcmd <filename>');
|
||||
Halt(1);
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
OutStream: TFileStream;
|
||||
Project: TChmProject;
|
||||
|
||||
begin
|
||||
if Paramcount = 1 then begin
|
||||
if (Paramcount=1) and (ParamStr(1)<>'-h') and (ParamStr(1)<>'-?') then
|
||||
begin
|
||||
Project := TChmProject.Create;
|
||||
Project.LoadFromFile(ParamStr(1));
|
||||
OutStream := TFileStream.Create(Project.OutputFileName, fmCreate, fmOpenWrite);
|
||||
Project.WriteChm(OutStream);
|
||||
OutStream.Free;
|
||||
Project.Free;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Usage;
|
||||
end;
|
||||
end.
|
||||
|
||||
|
||||
@ -76,14 +76,28 @@ begin
|
||||
WriteLn(Name);
|
||||
end;
|
||||
|
||||
Procedure Usage;
|
||||
|
||||
begin
|
||||
WriteLn(' Usage: chmls filename.chm [section number]');
|
||||
Halt(1);
|
||||
end;
|
||||
|
||||
// Start of program
|
||||
begin
|
||||
if Paramcount < 1 then begin
|
||||
WriteLn(' Usage: chmls filename.chm [section number]');
|
||||
exit;
|
||||
end;
|
||||
if ParamCount > 1 then Section := StrToInt(ParamStr(2));
|
||||
|
||||
if (Paramcount < 1) or (Paramstr(1)='-h') or (Paramstr(1)='-?') then
|
||||
begin
|
||||
usage;
|
||||
end;
|
||||
if ParamCount > 1 then
|
||||
begin
|
||||
Section := StrToIntDef(ParamStr(2),-1);
|
||||
If (Section=-1) then
|
||||
begin
|
||||
Usage;
|
||||
Halt(1);
|
||||
end;
|
||||
end;
|
||||
Stream := TFileStream.Create(ParamStr(1), fmOpenRead);
|
||||
JunkObject := TJunkObject.Create;
|
||||
ITS:= TITSFReader.Create(Stream, True);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user