--- phase: 11-refactor plan: 01 type: execute wave: 1 depends_on: [] files_modified: - InputArgs.cs - Program.cs - AesCrypt.cs autonomous: true --- ## Goal Extract arg parsing into dedicated `ArgParser` static class; clean `Program.cs` control flow; delete dead `AesCrypt.cs`. ## Purpose Program.cs currently mixes arg parsing, license check, business dispatch, and output formatting in one file. Separating concerns makes each part testable and readable. No behavior change — same inputs produce same outputs. ## Output - New `ArgParser.cs` (static class, pure function: `string[] → InputArgs`) - `Program.cs` simplified: Main calls `ArgParser.Parse`, then dispatches - `AesCrypt.cs` deleted - All existing tests still pass @.paul/PROJECT.md @Program.cs @InputArgs.cs @AesCrypt.cs ## AC-1: ArgParser extracted ```gherkin Given string[] args with valid parameters When ArgParser.Parse(args) is called Then returns populated InputArgs with correct field values ``` ## AC-2: Program.cs simplified ```gherkin Given Program.cs When read Then Main has no inline regex or arg-parsing logic — delegates entirely to ArgParser.Parse ``` ## AC-3: AesCrypt deleted ```gherkin Given AesCrypt.cs (dead code, nothing references it) When file is deleted Then project still compiles with no errors ``` Task 1: Create ArgParser.cs ArgParser.cs Create static class `NcProgramManager.ArgParser` with single public method: `public static InputArgs Parse(string[] args)` Move ALL logic from `parseArgomenti` in Program.cs into this method verbatim, then adapt signature (returns InputArgs instead of mutating field). Rules: - Keep same regex patterns and substring offsets — no behavior change - Throw same exceptions on parse failure (caller catches in Main) - Class is internal static, method is internal static - No new dependencies ArgParser.cs compiles; `ArgParser.Parse(new[]{"-help"}).mostraHelp == true` AC-1 satisfied: ArgParser.Parse returns correct InputArgs Task 2: Simplify Program.cs Program.cs Replace `parseArgomenti` call with `inputArgs = ArgParser.Parse(args)`. Delete `parseArgomenti` method body from Program.cs entirely. Remove the `private static InputArgs inputArgs = new InputArgs()` field — declare `InputArgs inputArgs` as local variable in Main instead. Pass `inputArgs` explicitly to `Scarica(machine, inputArgs)` and `Invia(machine, inputArgs)`. Update Scarica/Invia signatures to accept `InputArgs` parameter (no longer use static field). `vediErrore` already uses `inputArgs.debugMode` — pass it as parameter too, or make vediErrore accept `bool debugMode`. Do NOT change license check, MostraAiuto, vediErrore content, or error codes. Project compiles. `dotnet build` (or msbuild) reports 0 errors. Scarica/Invia no longer reference static field. AC-2 satisfied: Main delegates to ArgParser, no inline regex Task 3: Delete AesCrypt.cs AesCrypt.cs Verify no file in the project references `AesCrypt` (grep before deleting). Delete AesCrypt.cs. Remove its entry from NcProgramManager.csproj `` list if present. grep -r "AesCrypt" . --include="*.cs" returns no results. Project compiles. AC-3 satisfied: dead code removed, project still compiles ## DO NOT CHANGE - Cnc/* — all machine implementation files - Licensing/* — license system - FanucProgram.cs, fwlib32.cs - Error codes in vediErrore - MostraAiuto content (README task handles docs) - NcProgramManager.Tests/* ## SCOPE LIMITS - No behavior change — same CLI args produce same results - Do not refactor Scarica/Invia error handling (that is Plan 11-02) - Do not add new error messages or change exit codes Before declaring plan complete: - [ ] grep -r "AesCrypt" . --include="*.cs" returns 0 results - [ ] grep "parseArgomenti" Program.cs returns 0 results - [ ] Project compiles (msbuild or dotnet build) - [ ] ArgParser.cs exists at project root - [ ] All tests pass (NcProgramManager.Tests) - ArgParser.cs created, all parsing logic moved - Program.cs Main has no regex or substring parsing - AesCrypt.cs deleted and removed from csproj - Zero compilation errors - Zero test regressions After completion, create `.paul/phases/11-refactor/11-01-SUMMARY.md`