-
-
Notifications
You must be signed in to change notification settings - Fork 22
Add missing CLI tools for TUI parity #166
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds CLI commands for existing TUI (Terminal User Interface) tools and refactors shared conversion logic into reusable internal packages to achieve parity between CLI and TUI functionality.
Changes:
- Extracts conversion logic into 6 new internal packages (yamlfmt, uuidutil, structgen, numbers, htmlfmt, csv2json)
- Refactors 9 TUI modules to use the new shared internal packages
- Adds 8 new CLI commands with corresponding test coverage (yamlstruct, yamlfmt, uuidgenerate, uuiddecode, numbers, jsonstruct, htmlfmt, csv2json)
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/yamlfmt/yamlfmt.go | New package for YAML formatting with proper encoder cleanup |
| internal/uuidutil/uuidutil.go | New package consolidating UUID generation and decoding utilities |
| internal/structgen/structgen.go | New package for JSON/YAML to Go struct conversion |
| internal/numbers/numbers.go | New package for number base conversion operations |
| internal/htmlfmt/htmlfmt.go | New package wrapping HTML formatting functionality |
| internal/csv2json/csv2json.go | New package for CSV to JSON conversion with improved error wrapping |
| tui/yamlstruct/yamlstruct.go | Refactored to use internal/structgen package |
| tui/yaml/main.go | Refactored to use internal/yamlfmt package |
| tui/uuid-generate/main.go | Refactored to use internal/uuidutil package |
| tui/uuid-decode/main_test.go | Updated test to use internal/uuidutil package |
| tui/uuid-decode/main.go | Refactored to use internal/uuidutil package |
| tui/numbers/main.go | Refactored to use internal/numbers package with improved type safety |
| tui/jsonstruct/jsonstruct.go | Refactored to use internal/structgen package |
| tui/html/main.go | Refactored to use internal/htmlfmt package |
| tui/csv2json/main.go | Refactored to use internal/csv2json package |
| cmd/yamlstruct.go | New CLI command for YAML to Go struct conversion |
| cmd/yamlstruct_test.go | Test coverage for yamlstruct CLI command |
| cmd/yamlfmt.go | New CLI command for YAML formatting |
| cmd/yamlfmt_test.go | Test coverage for yamlfmt CLI command |
| cmd/uuidgenerate.go | New CLI command for UUID generation with version support |
| cmd/uuidgenerate_test.go | Test coverage for uuidgenerate CLI command |
| cmd/uuiddecode.go | New CLI command for UUID decoding with JSON output option |
| cmd/uuiddecode_test.go | Test coverage for uuiddecode CLI command |
| cmd/numbers.go | New CLI command for number base conversion with JSON output option |
| cmd/numbers_test.go | Test coverage for numbers CLI command |
| cmd/jsonstruct.go | New CLI command for JSON to Go struct conversion |
| cmd/jsonstruct_test.go | Test coverage for jsonstruct CLI command |
| cmd/htmlfmt.go | New CLI command for HTML formatting |
| cmd/htmlfmt_test.go | Test coverage for htmlfmt CLI command |
| cmd/csv2json.go | New CLI command for CSV to JSON conversion |
| cmd/csv2json_test.go | Test coverage for csv2json CLI command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| uuidStr := strings.TrimSpace(inputStr) | ||
| if uuidStr == "" { | ||
| return errors.New("no input provided. pipe UUID input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe UUID input to this command".
| } | ||
| value := strings.TrimSpace(inputStr) | ||
| if value == "" { | ||
| return errors.New("no input provided. pipe number input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe number input to this command".
| return fmt.Errorf("error reading from stdin: %w", err) | ||
| } | ||
| if len(data) == 0 { | ||
| return errors.New("no input provided. pipe JSON input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe JSON input to this command".
| return fmt.Errorf("error reading from stdin: %w", err) | ||
| } | ||
| if len(data) == 0 { | ||
| return errors.New("no input provided. pipe HTML input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe HTML input to this command".
| return fmt.Errorf("error reading from stdin: %w", err) | ||
| } | ||
| if len(data) == 0 { | ||
| return errors.New("no input provided. pipe CSV input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe CSV input to this command".
| if len(result.Conversions) == 0 { | ||
| t.Fatalf("expected conversions in JSON output") | ||
| } | ||
| } |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test for the no input case, which is present in other command tests (e.g., cmd/yamlstruct_test.go:33, cmd/yamlfmt_test.go:30, cmd/uuiddecode_test.go:63). A test like TestNumbersCmdNoInput should be added to verify that the command returns an error when no input is provided, consistent with the testing pattern used throughout the codebase.
| return fmt.Errorf("error reading from stdin: %w", err) | ||
| } | ||
| if len(data) == 0 { | ||
| return errors.New("no input provided. pipe YAML input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe YAML input to this command".
| return fmt.Errorf("error reading from stdin: %w", err) | ||
| } | ||
| if len(data) == 0 { | ||
| return errors.New("no input provided. pipe YAML input to this command") |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses lowercase "pipe" but existing commands in the codebase use capitalized "Pipe" (see cmd/json2yaml.go:39, cmd/json2toml.go:48, cmd/xml2json.go:39). For consistency with the established convention, this should be "no input provided. Pipe YAML input to this command".
Summary
internal/and reuse them in TUI modules