Skip to content

Conversation

@skatkov
Copy link
Owner

@skatkov skatkov commented Jan 24, 2026

Summary

  • add CLI commands for YAML/HTML formatting, CSV/struct conversion, numbers, and UUID tools
  • extract shared conversion helpers into internal/ and reuse them in TUI modules
  • add CLI tests covering the new commands

Copy link

Copilot AI left a 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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
}
value := strings.TrimSpace(inputStr)
if value == "" {
return errors.New("no input provided. pipe number input to this command")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
if len(result.Conversions) == 0 {
t.Fatalf("expected conversions in JSON output")
}
}
Copy link

Copilot AI Jan 24, 2026

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.

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jan 24, 2026

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".

Copilot uses AI. Check for mistakes.
@skatkov skatkov merged commit 78b723f into main Jan 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants