diff --git a/src/wattsi.pas b/src/wattsi.pas index 542fd3f..fd6e31e 100644 --- a/src/wattsi.pas +++ b/src/wattsi.pas @@ -2872,6 +2872,14 @@ function Split(const Document: TDocument; var BigTOC: TElement; const Base: Ansi SectionNames.Free(); end; +function PrintUsageAndHalt(): Boolean; +begin; + Writeln('syntax:'); + Writeln(' wattsi [--quiet] [--single-page-only] []'); + Writeln(' wattsi --version'); + Halt(1); +end; + function Main(): Boolean; const OtherVariants = [Low(TVariants)..High(TVariants)] - [Low(TVariants)]; @@ -2889,6 +2897,11 @@ function Main(): Boolean; i: integer; begin Result := False; + if (ParamCount = 0) then + begin + Writeln('wattsi: missing required arguments'); + PrintUsageAndHalt(); + end; if ((ParamCount() = 1) and (ParamStr(1) = '--version')) then begin Writeln('wattsi ' + IntToStr(Version)); @@ -2912,10 +2925,7 @@ function Main(): Boolean; if ((ParamCount() - i) < 4) then begin Writeln('wattsi: invalid arguments'); - Writeln('syntax:'); - Writeln(' wattsi [--quiet] [--single-page-only] []'); - Writeln(' wattsi --version'); - exit; + PrintUsageAndHalt(); end; SourceFile := ParamStr(i); SourceGitSHA := ParamStr(i + 1);