Skip to content

Commit c7f426a

Browse files
authored
Review exit codes / prep for release (#15)
* Remove-FileList and Remove-DirectoryList — added a FailedCount property on their result object. Previously the catch block called Write-Warning and Write-Error but neither bubbled up to the outer try/catch (the inner catch consumed the exception), so failures were invisible to the exit code logic. Now failures increment FailedCount and the error message is surfaced via Write-Warning with the exception message included for diagnostics. Issue #11 * Updated comments explaining exit codes * Opportunistic fix: -Whatif not displaying items that would be deleted * Target working folder, not parent. Reversing an idea that seemed good at the time... * Comments updated - problem in letting Claude edit * Streamline parameters: -ExcludeDirectoryPattern replace -ExcludeDirPattern + -ExcludeDirectories * Streamline parameters: -ExcludeDirectoryPattern replace -ExcludeDirPattern + -ExcludeDirectories * Streamline parameters: -ExcludeDirectoryPattern replace -ExcludeDirPattern + -ExcludeDirectories * Document supported exit codes in Readme for #11
1 parent f6af05d commit c7f426a

4 files changed

Lines changed: 114 additions & 135 deletions

File tree

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pwsh -File .\delphi-clean.ps1 -Level deep -Json
3737
- Optional structured output via `-PassThru`
3838
- Supports the `-WhatIf` dry-run mode
3939
- Add extra file patterns with `-IncludeFilePattern`
40-
- Exclude directories by wildcard pattern with `-ExcludeDirPattern`
40+
- Exclude directories by wildcard pattern with `-ExcludeDirectoryPattern`
4141
- Send items to the recycle bin / trash instead of permanent deletion with `-RecycleBin`
4242

4343
---
@@ -129,16 +129,6 @@ Outputs a JSON summary including:
129129

130130
---
131131

132-
### Exclude Directories
133-
134-
```powershell
135-
pwsh -File .\delphi-clean.ps1 -ExcludeDirectories .git,.vs,.idea
136-
```
137-
138-
Matches exact directory names. Default exclusions are `.git`, `.vs`, and `.claude`.
139-
140-
---
141-
142132
### Include Extra File Patterns
143133

144134
```powershell
@@ -154,13 +144,14 @@ project-specific artifacts not covered by the standard levels.
154144
### Exclude Directory Patterns
155145

156146
```powershell
157-
pwsh -File .\delphi-clean.ps1 -ExcludeDirPattern 'vendor*'
158-
pwsh -File .\delphi-clean.ps1 -ExcludeDirPattern 'vendor*','assets'
147+
pwsh -File .\delphi-clean.ps1 -ExcludeDirectoryPattern 'vendor*'
148+
pwsh -File .\delphi-clean.ps1 -ExcludeDirectoryPattern 'vendor*','assets'
159149
```
160150

161151
Skips any directory whose name matches one of the given wildcard patterns.
162-
Unlike `-ExcludeDirectories`, patterns are matched with `-like` so wildcards
163-
(`*`, `?`) are supported.
152+
Patterns are matched with `-like` so wildcards (`*`, `?`) are supported.
153+
154+
Specific directories are excluded by default: `.git`, `.vs`, and `.claude`.
164155

165156
---
166157

@@ -223,6 +214,18 @@ Includes everything in `standard`, plus:
223214

224215
---
225216

217+
## Exit Codes
218+
219+
```text
220+
0 = success: every matched item was removed (or WhatIf run, or nothing to clean)
221+
1 = fatal: unhandled exception before or during the scan phase - bad root path,
222+
unsupported platform for -RecycleBin, scan error, etc.
223+
2 = partial: the script reached the removal phase but at least one item could not
224+
be deleted or recycled; successfully removed items are not rolled back
225+
```
226+
227+
---
228+
226229
## Maturity
227230

228231
This repository is currently `incubator` and is under active development.

docs/cleanup-levels.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# delphi-clean levels
22

3-
This document defines the cleanup levels and per-invocation extension
4-
parameters used by `delphi-clean.ps1`.
3+
This document defines the default cleanup levels used by `delphi-clean.ps1`.
54

65
Each level is cumulative:
76

@@ -95,58 +94,3 @@ Includes everything in `standard`, plus the following additional items.
9594
### Additional Directories
9695

9796
- `__recovery`
98-
99-
---
100-
101-
## Per-invocation extension parameters
102-
103-
These parameters are independent of the chosen level and can be combined
104-
with any level.
105-
106-
### `-IncludeFilePattern <string[]>`
107-
108-
Adds one or more extra wildcard file patterns to the deletion set for this
109-
run. Use this for project-specific files that are intentionally omitted
110-
from the built-in levels.
111-
112-
Example -- delete compiled resource files in addition to the `basic` set:
113-
114-
delphi-clean.ps1 -Level basic -IncludeFilePattern '*.res'
115-
116-
Example -- delete multiple extra patterns:
117-
118-
delphi-clean.ps1 -Level standard -IncludeFilePattern '*.res','*.mab'
119-
120-
### `-ExcludeDirPattern <string[]>`
121-
122-
Skips any directory whose name matches one of the supplied wildcard
123-
patterns. This supplements the fixed `-ExcludeDirectories` list and is
124-
useful when a project folder (such as `assets` or a vendor subtree)
125-
contains files that would otherwise match the cleanup patterns.
126-
127-
Example -- protect an assets folder from cleanup:
128-
129-
delphi-clean.ps1 -Level basic -ExcludeDirPattern 'assets'
130-
131-
Example -- wildcard to protect all vendor-prefixed folders:
132-
133-
delphi-clean.ps1 -Level standard -ExcludeDirPattern 'vendor*'
134-
135-
Both parameters may be combined:
136-
137-
delphi-clean.ps1 -Level basic -IncludeFilePattern '*.res' -ExcludeDirPattern 'assets','vendor*'
138-
139-
### `-RecycleBin`
140-
141-
Sends deleted items to the platform trash instead of permanently removing them.
142-
Supported on Windows (Recycle Bin), macOS (`~/.Trash/`), and Linux
143-
(`~/.local/share/Trash/` per the FreeDesktop spec).
144-
145-
Example:
146-
147-
delphi-clean.ps1 -Level standard -RecycleBin
148-
149-
Can be combined with `-WhatIf` to preview which items would be recycled without
150-
making any changes:
151-
152-
delphi-clean.ps1 -Level standard -RecycleBin -WhatIf

0 commit comments

Comments
 (0)