Skip to content

Refactor list-available command to support json format #387

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

roulpriya
Copy link
Contributor

@roulpriya roulpriya force-pushed the refactor-list-available-command-to-support-json-output branch 3 times, most recently from d996fe5 to 777e46b Compare June 17, 2025 11:05
struct AvailableToolchainInfo: OutputData {
let version: ToolchainVersion
let inUse: Bool
let `default`: Bool
Copy link
Member

Choose a reason for hiding this comment

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

thought: I'm not sure how I feel about using language keywords for fields, even though Swift allows us to escape it like this. It feels like it should be used very sparingly since it forces all of the call sites to use the back-ticks, which can look confusing, and noisy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with you. I'll rename to isDefault

return "{}"
let jsonData = try encoder.encode(data)
guard let result = String(data: jsonData, encoding: .utf8) else {
throw OutputFormatterError.encodingError("Failed to convert JSON data to string.")
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: This message is in relation to converting byte Data to a String using the UTF8 encoding. This could be reworded a bit to something that makes this a bit more clear in the very rare case where it occurs. How about something like "failed to encode JSON data as a string in UTF-8"?

@roulpriya roulpriya marked this pull request as draft June 17, 2025 16:11
@roulpriya roulpriya force-pushed the refactor-list-available-command-to-support-json-output branch from 777e46b to 046d741 Compare June 17, 2025 16:53
@roulpriya roulpriya marked this pull request as ready for review June 17, 2025 16:54
@roulpriya roulpriya force-pushed the refactor-list-available-command-to-support-json-output branch from 046d741 to 8424f8e Compare June 17, 2025 17:12
@cmcgee1024 cmcgee1024 merged commit 4fa8b10 into swiftlang:main Jun 17, 2025
24 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