Skip to content
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
merged 10 commits into from
Jul 4, 2024

Conversation

supitsdu
Copy link
Owner

@supitsdu supitsdu commented Jul 3, 2024

Description

Update ContentReader, Dependencies, and README.md for Enhanced Functionality

Changes Made

  • Implemented ContentReader to manage file contents and input streams efficiently.
  • Updated dependencies in go.mod to include github.com/gabriel-vasile/mimetype v1.4.4 and github.com/stretchr/testify v1.9.0.
  • Enhanced README.md with new features like Mimetype & Codeblock and clarified installation instructions.

Checklist

  • Implemented ContentReader for file content management.
  • Updated dependencies in go.mod.
  • Enhanced README.md with new features and installation instructions.
  • Verified changes with appropriate tests.

supitsdu added 8 commits July 1, 2024 01:37
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 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
@supitsdu supitsdu self-assigned this Jul 3, 2024
cli/reader/reader.go Outdated Show resolved Hide resolved
supitsdu added 2 commits July 4, 2024 00:57
- 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.
@supitsdu supitsdu removed the in-progress Issues or PRs currently being worked on. label Jul 4, 2024
@supitsdu supitsdu merged commit 215b33d into main Jul 4, 2024
1 check passed
@supitsdu supitsdu deleted the feature/content-formats branch July 4, 2024 04:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants