Skip to content

Fix swift package init --help printout #3407

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

Merged
merged 7 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// The 'swift-argument-parser' version declared here must match that
// used by 'swift-driver' and 'sourcekit-lsp'. Please coordinate
// dependency version changes here with those projects.
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.1")),
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.4.3")),
Copy link
Contributor

Choose a reason for hiding this comment

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

please work @shahmishal to also update the toolchain CI definition

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this also needs to be coordinated with https://github.com/apple/swift-driver/blob/main/Package.swift#L134

cc @artemcm

.package(url: "https://github.com/apple/swift-driver.git", .branch(relatedDependenciesBranch)),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.4")),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/Commands/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ public struct SwiftToolOptions: ParsableArguments {

@Flag(name: .customLong("index-store"), inversion: .prefixedEnableDisable, help: "Enable or disable indexing-while-building feature")
var indexStoreEnable: Bool?

/// The mode to use for indexing-while-building feature.
var indexStore: BuildParameters.IndexStoreMode {
guard let enable = indexStoreEnable else { return .auto }
return enable ? .on : .off
}

/// Whether to enable generation of `.swiftinterface`s alongside `.swiftmodule`s.
@Flag(name: .customLong("enable-parseable-module-interfaces"))
var shouldEnableParseableModuleInterfaces: Bool = false
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/SwiftBuildTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public struct SwiftBuildTool: SwiftCommand {
version: SwiftVersion.currentVersion.completeDisplayString,
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down
70 changes: 37 additions & 33 deletions Sources/Commands/SwiftPackageTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Delete build artifacts")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -90,7 +90,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Purge the global repository cache.")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -102,7 +102,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Reset the complete cache/build directory")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -114,7 +114,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Update package dependencies")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Flag(name: [.long, .customShort("n")],
Expand Down Expand Up @@ -160,10 +160,10 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Describe the current package")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option()
@Option(help: "json | text")
var type: DescribeMode = .text

func run(_ swiftTool: SwiftTool) throws {
Expand Down Expand Up @@ -191,21 +191,22 @@ extension SwiftPackageTool {
}

struct Init: SwiftCommand {
static let configuration = CommandConfiguration(
public static let configuration = CommandConfiguration(
abstract: "Initialize a new package")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(name: .customLong("type"))
@Option(name: .customLong("type"), help: "Package type: empty | library | executable | system-module | manifest")
var initMode: InitPackage.PackageType = .library

@Option(name: .customLong("name"), help: "Provide custom package name")
var packageName: String?

func run(_ swiftTool: SwiftTool) throws {
// FIXME: Error handling.
let cwd = localFileSystem.currentWorkingDirectory!
guard let cwd = localFileSystem.currentWorkingDirectory else {
throw InternalError("Could not find the current working directory")
}

let packageName = self.packageName ?? cwd.basename
let initPackage = try InitPackage(
Expand All @@ -221,7 +222,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
commandName: "_format")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Argument(parsing: .unconditionalRemaining,
Expand Down Expand Up @@ -291,7 +292,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
commandName: "experimental-api-diff")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Argument(help: "The baseline treeish")
Expand Down Expand Up @@ -343,7 +344,10 @@ extension SwiftPackageTool {
}

struct DumpSymbolGraph: SwiftCommand {
@OptionGroup()
static let configuration = CommandConfiguration(
abstract: "Dump Symbol Graph")

@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -366,7 +370,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Print parsed Package.swift as JSON")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -390,7 +394,7 @@ extension SwiftPackageTool {
}

struct DumpPIF: SwiftCommand {
@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Flag(help: "Preserve the internal structure of PIF")
Expand All @@ -409,7 +413,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Put a package in editable mode")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(help: "The revision to edit", transform: { Revision(identifier: $0) })
Expand Down Expand Up @@ -442,7 +446,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Remove a package from editable mode")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Flag(name: .customLong("force"),
Expand All @@ -469,10 +473,10 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Print the resolved dependency graph")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option()
@Option(help: "text | dot | json | flatlist")
var format: ShowDependenciesMode = .text

func run(_ swiftTool: SwiftTool) throws {
Expand All @@ -486,10 +490,10 @@ extension SwiftPackageTool {
commandName: "tools-version",
abstract: "Manipulate tools version of the current package")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option()
@Option(help: "text | dot | json | flatlist")
var format: ShowDependenciesMode = .text

@Flag(help: "Set tools version of package to the current tools version in use")
Expand Down Expand Up @@ -545,7 +549,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Compute the checksum for a binary artifact.")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Argument(help: "The absolute or relative path to the binary artifact")
Expand Down Expand Up @@ -573,7 +577,7 @@ extension SwiftPackageTool {
abstract: "Create a source archive for the package"
)

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(
Expand Down Expand Up @@ -635,7 +639,7 @@ extension SwiftPackageTool {
var skipExtraFiles: Bool = false
}

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down Expand Up @@ -711,7 +715,7 @@ extension SwiftPackageTool.Config {
static let configuration = CommandConfiguration(
abstract: "Set a mirror for a dependency")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(help: "The package dependency url")
Expand Down Expand Up @@ -745,7 +749,7 @@ extension SwiftPackageTool.Config {
static let configuration = CommandConfiguration(
abstract: "Remove an existing mirror")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(help: "The package dependency url")
Expand Down Expand Up @@ -779,7 +783,7 @@ extension SwiftPackageTool.Config {
static let configuration = CommandConfiguration(
abstract: "Print mirror configuration for the given package dependency")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Option(help: "The package dependency url")
Expand Down Expand Up @@ -831,7 +835,7 @@ extension SwiftPackageTool {
static let configuration = CommandConfiguration(
abstract: "Resolve package dependencies")

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down Expand Up @@ -861,7 +865,7 @@ extension SwiftPackageTool {
struct Fetch: SwiftCommand {
static let configuration = CommandConfiguration(shouldDisplay: false)

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down Expand Up @@ -905,10 +909,10 @@ extension SwiftPackageTool {
)
}

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@Argument()
@Argument(help: "generate-bash-script | generate-zsh-script |\ngenerate-fish-script | list-dependencies | list-executables")
Copy link
Contributor

@tomerd tomerd Apr 22, 2021

Choose a reason for hiding this comment

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

Can the argument parser library enumerate the enum options instead of having to explicitly spell them like this? cc @natecook1000

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe with ExpressibleByArgument, I know that it's responsible for filling in default: x

var mode: Mode

func run(_ swiftTool: SwiftTool) throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/SwiftRunTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public struct SwiftRunTool: SwiftCommand {
version: SwiftVersion.currentVersion.completeDisplayString,
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
public var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/SwiftTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public struct SwiftTestTool: SwiftCommand {
version: SwiftVersion.currentVersion.completeDisplayString,
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])

@OptionGroup()
@OptionGroup(_hiddenFromHelp: true)
var swiftOptions: SwiftToolOptions

@OptionGroup()
Expand Down