Skip to content

[#187] Fix export hint path and ExportError conformance#195

Merged
bguidolim merged 1 commit intomainfrom
feature/187-export-hint-path-and-error-conformance
Mar 1, 2026
Merged

[#187] Fix export hint path and ExportError conformance#195
bguidolim merged 1 commit intomainfrom
feature/187-export-hint-path-and-error-conformance

Conversation

@bguidolim
Copy link
Copy Markdown
Collaborator

Context

Fixes #187. The mcs export command had two issues:

  1. The post-export hint (mcs pack add <path>) printed the raw outputDir argument instead of the resolved absolute path, producing broken suggestions for relative paths.
  2. ExportError used CustomStringConvertible instead of LocalizedError, so ArgumentParser could display generic error messages instead of the custom descriptions.

Changes

  • Pass resolved outputURL.path to printPostExportHints() and use it in the hint
  • Change ExportError to conform to LocalizedError with errorDescription, matching MCSError and ManifestError conventions

Testing Steps

  • swift build passes
  • Run mcs export ./relative-path and verify the hint shows an absolute path
  • Trigger an ExportError (e.g. export to an existing directory) and verify the custom message displays

Copilot AI review requested due to automatic review settings March 1, 2026 23:49
Copy link
Copy Markdown

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

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.path into printPostExportHints() and use it in the mcs pack add ... hint.
  • Update ExportError to conform to LocalizedError with errorDescription (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 outputPath directly into a shell command. If the path contains spaces (common on macOS), the suggested mcs 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
@bguidolim bguidolim force-pushed the feature/187-export-hint-path-and-error-conformance branch from d95f3b1 to 1e47823 Compare March 1, 2026 23:55
@bguidolim bguidolim merged commit da4542b into main Mar 1, 2026
3 checks passed
@bguidolim bguidolim deleted the feature/187-export-hint-path-and-error-conformance branch March 1, 2026 23:58
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.

Export: post-export hint path mismatch and ExportError conformance

2 participants