Files
swift-argument-parser/Plugins/GenerateManual/GenerateManualPluginError.swift
Rauhul Varma 8f7e87bd0e Partially revert "Generate Manual" target name (#527)
- The name of "GenerateManualPlugin" was changed to "Generate Manual" to
  improve the plugin's display name in Xcode. This however results in
  the `.pluginWorkDirectory` provided by SPM to include a space (' ') in
  the path. The space in the output path by itself is not a deal
  breaker, but unfortunately `man` (at least on macOS) does not properly
  handle path arguments with spaces. Example:

  ```shell
  ➜  swift package generate-manual
  ...
  Generating manual for roll...
  Generated manual in '.build/plugins/Generate Manual/outputs/roll'
  ...
  ➜  man '.build/plugins/Generate Manual/outputs/roll/roll.1'
  /usr/bin/man: line 413: cd: .build/plugins/Generate: No such file or \
    directory
  ```

  IMO, easily previewing the generating manual takes precedence over the
  UI in Xcode; as a result, this commit partially reverts the plugin's
  name to "GenerateManual" to hopefully provide a good middle ground of
  an output path without a space and a display name in Xcode that is a
  little easier on the eyes than "GenerateManualPlugin" was.
2022-11-21 22:46:34 -08:00

51 lines
1.7 KiB
Swift

//===----------------------------------------------------------*- swift -*-===//
//
// This source file is part of the Swift Argument Parser open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
import Foundation
import PackagePlugin
enum GenerateManualPluginError: Error {
case unknownBuildConfiguration(String)
case buildFailed(String)
case createOutputDirectoryFailed(Error)
case subprocessFailedNonZeroExit(Path, Int32)
case subprocessFailedError(Path, Error)
}
extension GenerateManualPluginError: CustomStringConvertible {
var description: String {
switch self {
case .unknownBuildConfiguration(let configuration):
return "Build failed: Unknown build configuration '\(configuration)'."
case .buildFailed(let logText):
return "Build failed: \(logText)."
case .createOutputDirectoryFailed(let error):
return """
Failed to create output directory: '\(error.localizedDescription)'
"""
case .subprocessFailedNonZeroExit(let tool, let exitCode):
return """
'\(tool.lastComponent)' invocation failed with a nonzero exit code: \
'\(exitCode)'.
"""
case .subprocessFailedError(let tool, let error):
return """
'\(tool.lastComponent)' invocation failed: \
'\(error.localizedDescription)'
"""
}
}
}
extension GenerateManualPluginError: LocalizedError {
var errorDescription: String? { self.description }
}