-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance ContentReader with New Formatting Options and Code Refactoring #38
Merged
Conversation
This file contains 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
The variable names are now more intuitive, and the use of versionStr in GetVersion makes the logic easier to follow.
- Added flags for HTML, Markdown, MimeType, and LineNumbers formatting - Introduced ShouldFormat flag to determine if any formatting options are enabled - Updated ParseFlags to parse new command-line flags and set default values
- Added ContentReader struct holding a reference to Config for configuration-based content reading and formatting - Implemented ReadAll to read content from files or stdin and aggregate results - Introduced ReadFilesAsync for concurrent file reading using goroutines - Added JoinAll to aggregate content from multiple sources into a single string - Implemented ReadFile for reading and formatting content from a single file - Added Readable to check file readability and accessibility - Implemented IOReader for reading content from an io.Reader - Added CreateContent to apply formatting based on configuration - Implemented Format for HTML, Markdown, MIME type inclusion, and line numbering
- Updated Run to utilize the new ContentReader for reading and processing content - Improved error handling and aggregation of content from multiple sources
- Replaced direct instantiation of ContentReader with configuration-driven instantiation - Enhanced readability by defining reader and passing it to clipper.Run
- Added tests for ReadAll with multiple files - Added tests for ReadFile to ensure proper file reading - Added tests for Readable to verify file accessibility checks - Added tests for IOReader to handle reading from io.Reader - Added tests for CreateContent with and without formatting options (HTML, Markdown) - Added tests for JoinAll to aggregate multiple content strings
- Added github.com/gabriel-vasile/mimetype v1.4.4 for MIME type detection. - Added github.com/stretchr/testify v1.9.0 for testing assertions. Also updated indirect dependencies: - github.com/davecgh/go-spew v1.1.1 - github.com/pmezard/go-difflib v1.0.0 - golang.org/x/net v0.26.0 - gopkg.in/yaml.v3 v3.0.1
- Updated README.md file to include new features such as Mimetype & Codeblock. - Revised installation instructions to provide clearer guidance on using the install script and manual installation methods.
supitsdu
added
enhancement
New feature requests or enhancements.
in-progress
Issues or PRs currently being worked on.
refactoring
Issues or PRs to improving code structure, without changing its external behavior
cleanup
Minor changes to remove dead code, fix inconsistencies, etc.
labels
Jul 3, 2024
ccoVeille
reviewed
Jul 3, 2024
- Enhanced comments across ContentReader functions for better clarity and understanding. - Moved error check inside the goroutine before the mu.Lock() call in ReadFilesAsync to reduce mutex hold time and improve efficiency.
…ty contents - Enhanced comments for better documentation in reader.go and tests. - Added tests to cover scenarios where JoinAll receives empty contents, ensuring no extra new line is added for empty contents.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cleanup
Minor changes to remove dead code, fix inconsistencies, etc.
enhancement
New feature requests or enhancements.
refactoring
Issues or PRs to improving code structure, without changing its external behavior
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.
Description
Update
ContentReader
, Dependencies, and README.md for Enhanced FunctionalityChanges Made
ContentReader
to manage file contents and input streams efficiently.go.mod
to includegithub.com/gabriel-vasile/mimetype v1.4.4
andgithub.com/stretchr/testify v1.9.0
.README.md
with new features likeMimetype & Codeblock
and clarified installation instructions.Checklist
ContentReader
for file content management.go.mod
.README.md
with new features and installation instructions.