Here is a detailed checklist of all items to be implemented for the DTS tool.
Phase 1: Setup and Configuration
- Project: Create
dtsdirectory. - Project: Initialize Go module
github.com/fluxnull/dts. - Code: Create
main.gowith initial boilerplate (imports, constants). - Config: Define the
configstruct to hold all runtime parameters.
Phase 2: User Interface
- CLI: Implement parsing for all command-line flags (
-f,-l,-r,-nh,-q,-o,-n,-h). - CLI: Ensure
-r/--rangeflag correctly parses theSTART...ENDformat. - CLI: Implement validation to ensure exactly one of
-for-lis used. - CLI: Implement the
printHelp()function with the full, specified help text. - Interactive Mode (Windows):
- Implement logic in
main()to detect when to enter interactive mode. - Create the
runInteractiveMode()function. - In interactive mode, display file stats (name, path, total lines).
- Implement the series of interactive prompts for header, split mode, and count.
- Implement the animated processing spinner.
- Implement the "Press ENTER to exit" prompt on completion.
- Implement logic in
Phase 3: Core Functionality
- Helpers: Implement the
parseLineCount()function to handleK/Msuffixes. - File I/O: Implement file opening with
syscalloptimizations for Windows and Linux. - Core Logic: Implement the
countLinesAndIndex()function for concurrent, chunk-based line counting and sparse index creation. - Core Logic: Implement
resolveRange()to parse keywords (BOF,COF,EOF) and numbers. - Core Logic: Implement header extraction logic to read and store the first line as a byte slice.
- Core Logic: Implement the splitting algorithm for
-linesmode (single-pass streaming). - Core Logic: Implement the splitting algorithm for
-filesmode (two-pass, concurrent writers). - Core Logic: Implement the
generateName()function for creating formatted output filenames.
Phase 4: Finalization and Verification
- Assembly: Tie all components together in the
main()function to handle all execution paths. - Error Handling: Ensure robust error handling and that partial output files are deleted on failure.
- Testing:
- Test
-fmode with a sample file. - Test
-lmode with a sample file. - Test
-rmode with various ranges (numeric, keyword, mixed). - Test
-nhand-qflags. - On Windows, test the interactive drag-and-drop mode.
- Verify output files are byte-for-byte correct.
- Test
- Build: Create final cross-platform executables for Linux, Windows, and macOS.