Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

This PR fixes #3042

Changes

  • cmd/thv/app/common.go
  • cmd/thv/app/list.go
  • cmd/thv/app/mcp.go
  • cmd/thv/app/registry.go
  • cmd/thv/app/rm.go
  • cmd/thv/app/stop.go

- Add -g shorthand to --group flag in rm.go (was empty string)
- Add -a shorthand to --all flag in stop.go (was missing)
- Create AddFormatFlag helper function in common.go with -f shorthand
- Create ValidateFormat and ValidateFormatFlag helpers for validation
- Create ChainPreRunE helper to combine multiple PreRunE validators
- Refactor list.go, registry.go, and mcp.go to use shared AddFormatFlag
- Add format validation in PreRunE for all commands with format flags

Fixes stacklok#3042

Signed-off-by: majiayu000 <[email protected]>
func init() {
listCmd.Flags().BoolVarP(&listAll, "all", "a", false, "Show all workloads (default shows just running)")
listCmd.Flags().StringVar(&listFormat, "format", FormatText, "Output format (json, text, or mcpservers)")
AddFormatFlag(listCmd, &listFormat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should continue to list mcpservers as an allowed format for the thv list command

Copy link
Member

@eleftherias eleftherias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @majiayu000. I've left a comment about retaining backward compatibility in the thv list command.

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.

Add missing flag shorthands and use shared helpers

2 participants