Decouple GUI from console and remove console mode from GUI executable#43
Open
philpem wants to merge 19 commits intogeraldholdsworth:mainfrom
Open
Decouple GUI from console and remove console mode from GUI executable#43philpem wants to merge 19 commits intogeraldholdsworth:mainfrom
philpem wants to merge 19 commits intogeraldholdsworth:mainfrom
Conversation
- Remove unused ExtCtrls and HTTPProtocol dependencies from DiscImage.pas - Add conditional compilation to Utils.pas to exclude GUI code when NO_GUI defined - Create DiscImageContext.pas: shared context for disc image operations - Create CLICommands.pas: standalone CLI command processor without GUI dependencies - Create DiscImageManagerCLI.lpr: CLI-only console application entry point - Create DiscImageManagerCLI.lpi: Lazarus project file for CLI version - Create UtilsCLI.pas: CLI-compatible subset of utility functions This enables building a command-line version of the tool that does not require an X server or GUI toolkits, suitable for headless server use. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Add -dNO_GUI custom compiler option to all Release build modes (Linux 64-bit, Linux ARM, Windows 64-bit, macOS 64-bit, macOS ARM) so that GUI-dependent code is excluded when building the CLI version. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
TProgressProc is a private type inside TDiscImage class and not accessible from other units. Removed the progress callback functionality from TDiscImageContext as it's not needed for the CLI interface. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Implement URL percent-encoding/decoding functions locally to replace the dependency on HTTPProtocol unit which was removed for CLI support. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Rename local variables Free/Used/Total to FreeBytes/UsedBytes/TotalBytes to avoid conflict with the built-in TObject.Free method identifier. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Renamed local variable 'Params' to 'CmdParams' in DoRun method to avoid shadowing the inherited Params property from TCustomApplication. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
- Deleted UtilsCLI.pas as Utils.pas already has {$IFNDEF NO_GUI}
conditionals that make it work for both GUI and CLI builds
https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Changed build mode names to match DiscImageManager.lpi naming: - "Release Linux 64-bit" → "Release Linux 64 bit" - "Release Linux ARM" → "Release Linux ARM 64 bit" - "Release Windows 64-bit" → "Release Windows 64 bit" - "Release macOS 64-bit" → "Release macOS 64 bit" https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Changed UnitOutputDirectory from lib/ to lib-cli/ to prevent compiled units from conflicting between GUI and CLI builds. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
These are general-purpose string utilities that fit better alongside other string functions in Utils.pas. DiscImage.pas now uses Utils. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Claude/decouple UI processing p e02f
Add the following commands that were present in the GUI's console mode: - compact/defrag: Defragment disc image partitions - dirtitle: Change current directory title - exec/load/type: Change file addresses and filetypes - find: Search host filesystem (distinct from image search) - filetocsv: Batch CSV export of multiple images - filetype: Translate between filetype names and numbers - interleave: Change ADFS/AFS interleave method - list: Display text/BASIC file contents - report: Show detailed image report - runscript: Execute commands from a script file - savecsv: Save image catalogue as CSV - stamp: Set current timestamp on files - join/split: Placeholders (not implemented in GUI either) Also updated: - cat command output format to match GUI (shows boot option, timestamps, load/exec addresses, filetypes as appropriate for format) - Help text expanded with all commands and format options https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
- Remove 'info' command (not in GUI console) - Change 'ls' to behave like GUI: redirects to 'find *' (list host files) instead of being an alias for 'cat' - Remove unused ShowImageInfo procedure - Update help text accordingly https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
- CmdDefrag: Mark as not available in CLI mode (requires GUI infrastructure) - CmdList: Convert for-loop to while-loop to fix illegal assignment to loop variable when skipping CR+LF pairs https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
The "initial image file" detection used ParamStr(ParamCount) to grab the last command-line argument and try loading it as a disc image. When using `-s FOO.dim`, the script filename FOO.dim is the last argument, so it was incorrectly loaded as a disc image — causing EReadError since a text script file is not a valid disc image. Replace the naive ParamStr(ParamCount) approach with a FindPositionalArg helper that properly walks the argument list, skipping options and their values (-s, -e and their arguments, -n, -h flags), and returns only a true standalone positional argument intended as an image file path. https://claude.ai/code/session_01CctTMMjYE63p4GMLjhrh61
The CLI functionality is now provided by the standalone DiscImageManagerCLI binary, eliminating code duplication between the GUI console mode and CLI. Changes: - Remove ConsoleAppUnit.pas from GUI project - Remove MainUnit_Console.pas include from MainUnit.pas - Remove ParseCommand declaration from TMainForm - Remove CheckConsole call from main program - Update project file to remove ConsoleAppUnit Users wanting command-line access should use the separate CLI build which doesn't require X11/GUI dependencies. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
- Delete ConsoleAppUnit.pas (no longer used by GUI) - Delete MainUnit_Console.pas (no longer used by GUI) - Remove console fallback in ReportError that used cmdRed/cmdNormal - Simplify ReportError to always use GUI dialogs The CLI functionality is now provided by the standalone DiscImageManagerCLI binary. These old console mode files are no longer needed. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
Remove ConsoleAppUnit dependency and all console output code paths that used ANSI color codes (cmd* variables). The GUI build no longer has embedded console mode, so this unit now operates purely in GUI mode. https://claude.ai/code/session_01H1suvkNPi2MVsX1y9Qy86P
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This includes the changes from #42 and also removes the console mode code from the GUI.
I've made it a separate PR so we can decide separately if we want to go down this route. See #42 for more info on the main changes.
The advantage is this gives us two executables with a clear separation of roles - if you want to run commands from the command-line, you run
DiscImageManagerCLI- otherwise you runDiscImageManager.This also means there's no need for the GUI/console detection code which is currently causing issues on Linux (it seems to always think it's in console mode, but can be overridden with
DiscImageManager -g)If this gets merged, #42 needs to go first, probably as a squash merge to avoid cluttering the change history.