* Emit help text if options not correct

git-svn-id: trunk@11370 -
This commit is contained in:
michael 2008-07-12 12:35:35 +00:00
parent 0eb08af40e
commit 32d0e652ff
2 changed files with 36 additions and 8 deletions

View File

@ -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.

View File

@ -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);