Skip to content

feat: add custom flag types for human-readable bytes and regex support - #39

Merged
kazeburo merged 1 commit into
mainfrom
feat/add-byte-and-regexp
Oct 26, 2026
Merged

kazeburo merged 1 commit into
mainfrom
feat/add-byte-and-regexp

Conversation

@kazeburo

@kazeburo kazeburo commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

PR Type

Enhancement, Tests, Documentation


Description

  • Add human-readable byte and regex flag types.

  • Test valid and invalid custom flag inputs.

  • Document usage and add byte-parsing dependency.

  • Replace parse-exit pointer helper with new calls.


Diagram Walkthrough

flowchart LR
  input["Flag input"]
  bytes["Bytes"]
  regex["Re"]
  size["Byte count"]
  pattern["Compiled pattern"]
  input -- "parse size" --> bytes
  input -- "compile regex" --> regex
  bytes -- "returns" --> size
  regex -- "exposes" --> pattern
Loading

File Walkthrough

Relevant files
Enhancement
2 files
flaghuman.go
Parse human-readable sizes into byte counts                           
+16/-0   
flagregexp.go
Compile regex flags and expose pattern state                         
+35/-0   
Tests
2 files
flaghuman_test.go
Test valid and invalid byte-size inputs                                   
+20/-0   
flagregexp_test.go
Test empty, valid, and invalid regex inputs                           
+28/-0   
Miscellaneous
1 files
flagrun.go
Replace parse-exit pointer helper with `new` calls             
+5/-9     
Documentation
1 files
README.md
Document byte-size and regex flag usage                                   
+52/-0   
Dependencies
2 files
go.mod
Add `go-humanize` byte-parsing module requirement               
+1/-0     
go.sum
Update module checksums for dependency changes                     

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Build failure

new requires a type, but OK and UNKNOWN are exit-status values. These returns prevent the package from compiling; use an addressable value or retain the pointer helper.

	return nil, new(OK)
} else if flags.WroteHelp(err) {
	fmt.Fprintf(stdout, "%v\n", err)
	return nil, new(OK)
} else if err != nil {
	fmt.Fprintf(stderr, "%v\n", err)
	return nil, new(UNKNOWN)

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@kazeburo
kazeburo merged commit 2d488b4 into main Oct 26, 2026
3 checks passed
@kazeburo
kazeburo deleted the feat/add-byte-and-regexp branch October 26, 2026 14:04
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant