Skip to content

Enhance parameter handling#46

Merged
ziflex merged 1 commit into
mainfrom
feat/better-param-handling
May 28, 2026
Merged

Enhance parameter handling#46
ziflex merged 1 commit into
mainfrom
feat/better-param-handling

Conversation

@ziflex
Copy link
Copy Markdown
Member

@ziflex ziflex commented May 28, 2026

This pull request updates how runtime parameters are passed and parsed in the CLI, improving flexibility and compatibility with JSON values. The changes affect the CLI flag documentation, parameter parsing logic, and related tests, making parameter input more robust and user-friendly.

Parameter Parsing and CLI Improvements:

  • Changed the syntax for passing parameters from key:value to name=value, with support for both = and : as separators for backward compatibility. Parameter values are now parsed as JSON when possible; otherwise, they are treated as strings. [1] [2]
  • Improved error handling for invalid parameter input, with clear error messages for missing separators or empty parameter names. [1] [2]
  • Updated CLI documentation and help text to reflect the new parameter syntax and parsing behavior, including several usage examples in README.md and the flag descriptions. [1] [2] [3]

Testing Enhancements:

  • Refactored and expanded tests for parameter parsing to cover a wide range of valid and invalid inputs, ensuring correct parsing of strings, numbers, booleans, arrays, objects, and error cases. [1] [2]

Code Cleanup:

  • Removed an unused import from cmd/params.go for better code hygiene.

Copilot AI review requested due to automatic review settings May 28, 2026 16:21
Copy link
Copy Markdown
Contributor

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 PR updates CLI runtime parameter handling to prefer name=value, parse JSON values when possible, and document the new behavior while retaining legacy name:value support.

Changes:

  • Adds parseParam to validate names, support =/: separators, and fall back to raw strings when JSON parsing fails.
  • Expands parameter parsing tests for JSON and raw string values.
  • Updates README and flag help text for the new parameter syntax.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
README.md Documents new --param name=value usage and JSON parsing behavior.
cmd/params.go Implements updated parameter parsing and validation.
cmd/params_test.go Refactors and expands parsing tests.
cmd/flags.go Updates CLI help text for --param.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/params.go
Comment on lines +27 to +35
name, raw, ok := strings.Cut(input, "=")
if !ok {
name, raw, ok = strings.Cut(input, ":")
}

if !ok {
return "", nil, fmt.Errorf("invalid param %q: expected name=value", input)
}

@ziflex ziflex merged commit 3853dc8 into main May 28, 2026
9 checks passed
@ziflex ziflex deleted the feat/better-param-handling branch May 28, 2026 18:39
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