[#187] Fix export hint path and ExportError conformance#195
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes two user-facing issues in mcs export: the post-export “next steps” hint now prints the resolved output path, and ExportError now conforms to LocalizedError so ArgumentParser can display the intended custom error messages.
Changes:
- Pass
outputURL.pathintoprintPostExportHints()and use it in themcs pack add ...hint. - Update
ExportErrorto conform toLocalizedErrorwitherrorDescription(aligning with other error types in the repo).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Sources/mcs/Export/PackWriter.swift |
Switch ExportError from CustomStringConvertible to LocalizedError for proper CLI error rendering. |
Sources/mcs/Commands/ExportCommand.swift |
Use the resolved output path in post-export hints so suggested commands work for relative paths. |
Comments suppressed due to low confidence (1)
Sources/mcs/Commands/ExportCommand.swift:412
- The post-export hint interpolates
outputPathdirectly into a shell command. If the path contains spaces (common on macOS), the suggestedmcs pack add ...command will break. Consider quoting/escaping the path in the hint output (e.g., wrap in quotes when it contains whitespace, or use a small shell-escape helper for arguments).
output.plain(" 1. Review the generated techpack.yaml")
output.plain(" 2. Test with: mcs pack add \(outputPath)")
output.plain(" 3. Share via git: push to a repository and use mcs pack add <url>")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Resolve outputDir to absolute path inside printPostExportHints via standardizedFileURL - Change ExportError from CustomStringConvertible to LocalizedError with errorDescription
d95f3b1 to
1e47823
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Fixes #187. The
mcs exportcommand had two issues:mcs pack add <path>) printed the rawoutputDirargument instead of the resolved absolute path, producing broken suggestions for relative paths.ExportErrorusedCustomStringConvertibleinstead ofLocalizedError, so ArgumentParser could display generic error messages instead of the custom descriptions.Changes
outputURL.pathtoprintPostExportHints()and use it in the hintExportErrorto conform toLocalizedErrorwitherrorDescription, matchingMCSErrorandManifestErrorconventionsTesting Steps
swift buildpassesmcs export ./relative-pathand verify the hint shows an absolute pathExportError(e.g. export to an existing directory) and verify the custom message displays