The file structure has been updated to match Rust's Modularity Guidelines. This includes 1) splitting business logic functions into a library crate, and 2) using the entrypoint of the binary crate (main.rs) only to call the run() function in library crate.
This is a popular pattern to parse command-line arguments used in open-source projects such as Zed.
Handing responsibilities of each command to a separate module.
The responsibility of handling each type of command were delegated to the processors listed in src/processors directory. The main reference for modularising the code was the official guide.
Integrating itertools library's chunk function to create a file reader
A file reader has been created to read a file chunk-by-chunk. A chunk is defined by a number of lines of a file; for example, if chunk is given to be 10, read_file_by_batch of BatchFileReader will apply function f to each chunk of 10 lines.
Closes #24
Changes proposed in this pull request:
The file structure has been updated to match Rust's Modularity Guidelines. This includes 1) splitting business logic functions into a library crate, and 2) using the entrypoint of the binary crate (
main.rs
) only to call therun()
function in library crate.clap
's enum-based command parsingThis is a popular pattern to parse command-line arguments used in open-source projects such as Zed.
The responsibility of handling each type of command were delegated to the processors listed in
src/processors
directory. The main reference for modularising the code was the official guide.itertools
library'schunk
function to create a file readerA file reader has been created to read a file chunk-by-chunk. A chunk is defined by a number of lines of a file; for example, if
chunk
is given to be 10,read_file_by_batch
ofBatchFileReader
will apply functionf
to each chunk of 10 lines.As per official Rust Guideline on Tests, unit tests for the file reader were written where the logic is.