Skip to content

Commit

Permalink
Print usage if args not provided
Browse files Browse the repository at this point in the history
Fixes #77.
  • Loading branch information
abhillman authored Dec 2, 2024
1 parent 49e7807 commit b9c2803
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/wattsi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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] <source-file> <source-git-sha> <output-directory> <default-or-review> <mdn-spec-links/html.json> [<highlight-server-url>]');
Writeln(' wattsi --version');
Halt(1);
end;

function Main(): Boolean;
const
OtherVariants = [Low(TVariants)..High(TVariants)] - [Low(TVariants)];
Expand All @@ -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));
Expand All @@ -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] <source-file> <source-git-sha> <output-directory> <default-or-review> <mdn-spec-links/html.json> [<highlight-server-url>]');
Writeln(' wattsi --version');
exit;
PrintUsageAndHalt();
end;
SourceFile := ParamStr(i);
SourceGitSHA := ParamStr(i + 1);
Expand Down

0 comments on commit b9c2803

Please sign in to comment.