Skip to content

Commit b9c2803

Browse files
authored
Print usage if args not provided
Fixes #77.
1 parent 49e7807 commit b9c2803

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/wattsi.pas

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,6 +2872,14 @@ function Split(const Document: TDocument; var BigTOC: TElement; const Base: Ansi
28722872
SectionNames.Free();
28732873
end;
28742874

2875+
function PrintUsageAndHalt(): Boolean;
2876+
begin;
2877+
Writeln('syntax:');
2878+
Writeln(' wattsi [--quiet] [--single-page-only] <source-file> <source-git-sha> <output-directory> <default-or-review> <mdn-spec-links/html.json> [<highlight-server-url>]');
2879+
Writeln(' wattsi --version');
2880+
Halt(1);
2881+
end;
2882+
28752883
function Main(): Boolean;
28762884
const
28772885
OtherVariants = [Low(TVariants)..High(TVariants)] - [Low(TVariants)];
@@ -2889,6 +2897,11 @@ function Main(): Boolean;
28892897
i: integer;
28902898
begin
28912899
Result := False;
2900+
if (ParamCount = 0) then
2901+
begin
2902+
Writeln('wattsi: missing required arguments');
2903+
PrintUsageAndHalt();
2904+
end;
28922905
if ((ParamCount() = 1) and (ParamStr(1) = '--version')) then
28932906
begin
28942907
Writeln('wattsi ' + IntToStr(Version));
@@ -2912,10 +2925,7 @@ function Main(): Boolean;
29122925
if ((ParamCount() - i) < 4) then
29132926
begin
29142927
Writeln('wattsi: invalid arguments');
2915-
Writeln('syntax:');
2916-
Writeln(' wattsi [--quiet] [--single-page-only] <source-file> <source-git-sha> <output-directory> <default-or-review> <mdn-spec-links/html.json> [<highlight-server-url>]');
2917-
Writeln(' wattsi --version');
2918-
exit;
2928+
PrintUsageAndHalt();
29192929
end;
29202930
SourceFile := ParamStr(i);
29212931
SourceGitSHA := ParamStr(i + 1);

0 commit comments

Comments
 (0)