Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
macro expansion, custom-option parsing) into
`PasWeave.Lazarus.Support`; `PasWeave.Lazarus` now focuses on project and
package graph assembly.
- Split the CLI build pipeline into named `ParseCommandLine`,
`ExecuteBuild`, and `RenderAndReport` phases, leaving `RunBuild` as a short
orchestrator with one owner for option objects and build state.

## [0.7.0] - 2026-09-17

Expand Down
99 changes: 60 additions & 39 deletions src/cli/PasWeave.CLI.pas
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function RunBuild: Integer;
OldManifest: TManifest;
NewManifest: TManifest;
NewPaths: TStringList;
ParseHandled: Boolean;

procedure AppendConfigLine(const ALine: string);
begin
Expand Down Expand Up @@ -248,37 +249,8 @@ function RunBuild: Integer;
end;
end;

begin
SourcePath := '';
OutputPath := 'build/docs';
ProjectName := '';
ProjectNameExplicit := False;
BuildMode := '';
Verbose := False;
FailureSeverity := dsError;
HasMinimumCoverage := False;
MinimumCoverage := 0;
RepositoryURL := '';
SourceLinkTemplate := '';
ProjectMark := '';
ThemeAccent := '';
ThemeAccentAlt := '';
ThemeFont := '';
HasProjectMark := False;
HasThemeAccent := False;
HasThemeAccentAlt := False;
HasThemeFont := False;
CleanBuild := False;
SkipBuild := False;
Project := nil;
OldManifest := nil;
StartTick := MonotonicMilliseconds;
CommentStyles := DefaultDocumentationCommentStyles;
DiscoveryOptions := TSourceDiscoveryOptions.Create;
CompilerOptions := TCompilerOptions.Create;
PackagePaths := TStringList.Create;
LazarusConfiguration := nil;
try
procedure ParseCommandLine;
begin
I := 2;
while I <= ParamCount do
begin
Expand Down Expand Up @@ -489,7 +461,8 @@ function RunBuild: Integer;
else if (ParamStr(I) = '--help') or (ParamStr(I) = '-h') then
begin
PrintUsage;
Exit(0);
ParseHandled := True;
Exit;
end
else if (Length(ParamStr(I)) > 0) and (ParamStr(I)[1] = '-') then
raise EPasWeaveInputError.CreateFmt('unknown option: %s', [ParamStr(I)])
Expand All @@ -499,7 +472,12 @@ function RunBuild: Integer;
raise EPasWeaveInputError.Create('only one source path may be supplied');
Inc(I);
end;
end;

procedure ExecuteBuild;
var
I: Integer;
begin
if SourcePath = '' then
raise EPasWeaveInputError.Create('missing unit or source directory');
{ Validate before fingerprinting so a typo reports a clean input error
Expand Down Expand Up @@ -624,10 +602,12 @@ function RunBuild: Integer;
CommentStyles, DiscoveryOptions, CompilerOptions);
SamplePeakHeap;
end;
end;

if SkipBuild then
Exit;

function RenderAndReport: Integer;
var
I: Integer;
begin
if not TryConfigureSourceLinks(Project, RepositoryURL, SourceLinkTemplate,
SourceLinkError) then
raise EPasWeaveInputError.Create(SourceLinkError);
Expand Down Expand Up @@ -704,6 +684,47 @@ function RunBuild: Integer;
Result := 1
else
Result := 0;
end;

begin
SourcePath := '';
OutputPath := 'build/docs';
ProjectName := '';
ProjectNameExplicit := False;
BuildMode := '';
Verbose := False;
FailureSeverity := dsError;
HasMinimumCoverage := False;
MinimumCoverage := 0;
RepositoryURL := '';
SourceLinkTemplate := '';
ProjectMark := '';
ThemeAccent := '';
ThemeAccentAlt := '';
ThemeFont := '';
HasProjectMark := False;
HasThemeAccent := False;
HasThemeAccentAlt := False;
HasThemeFont := False;
CleanBuild := False;
SkipBuild := False;
Project := nil;
OldManifest := nil;
StartTick := MonotonicMilliseconds;
CommentStyles := DefaultDocumentationCommentStyles;
DiscoveryOptions := TSourceDiscoveryOptions.Create;
CompilerOptions := TCompilerOptions.Create;
PackagePaths := TStringList.Create;
LazarusConfiguration := nil;
ParseHandled := False;
try
ParseCommandLine;
if ParseHandled then
Exit(0);
ExecuteBuild;
if SkipBuild then
Exit;
Result := RenderAndReport;
finally
Project.Free;
OldManifest.Free;
Expand All @@ -719,10 +740,10 @@ function RunPasWeave: Integer;
try
if (ParamCount = 0) or (ParamStr(1) = '--help') or
(ParamStr(1) = '-h') then
begin
PrintUsage;
Exit(0);
end;
begin
PrintUsage;
Exit(0);
end;
if ParamStr(1) = '--version' then
begin
WriteLn('PasWeave ', PasWeaveVersion);
Expand Down
Loading