-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
@swift-ci please smoke test |
@natecook1000 ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @miggs597, this is great!
So with the custom mirror, does this still depend on the ArgumentParser PR? Or are both needed, i.e. even with the ArgumentParser PR, will the custom mirror continue to be needed?
|
||
static let includeSuperCommandInHelp = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided against requiring this bit for the ArgumentParser change.
static let includeSuperCommandInHelp = false |
All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help
To help us catch any possible regressions it would be nice to leverage |
@@ -908,7 +914,7 @@ extension SwiftPackageTool { | |||
@OptionGroup() | |||
var swiftOptions: SwiftToolOptions | |||
|
|||
@Argument() | |||
@Argument(help: "generate-bash-script | generate-zsh-script |\ngenerate-fish-script | list-dependencies | list-executables") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
// FIXME: Error handling. | ||
let cwd = localFileSystem.currentWorkingDirectory! | ||
guard let cwd = localFileSystem.currentWorkingDirectory else { | ||
throw StringError("Could not find the current working directory") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw InternalError in such case, as it would assert in debug mode which is what we want in this failure case
@@ -190,22 +190,25 @@ extension SwiftPackageTool { | |||
} | |||
} | |||
|
|||
struct Init: SwiftCommand { | |||
static let configuration = CommandConfiguration( | |||
public struct Init: SwiftCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to use AssertHelp
we need access to the commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use @testable import
to expose internal structures and functions for testing purposes. that is better than exposing more surface area in the public API.
AssertHelp(for: Commands.SwiftPackageTool.Init.self, equals: """ | ||
OVERVIEW: Initialize a new package | ||
|
||
USAGE: init [<options>] --enable-index-store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--enable-index-store ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's weird, but it does go away when they're all transitioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it does go away when they're all transitioned.
what does that mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another point is that I dont think its scalable to string match the the entire output of the --help
for each command. did you intend to add such tests to all commands or just this one as an indicator for the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't have to be for all the commands, I think it would be enough to have tests for the most popular commands: e.g. swift run
, swift build
, swift test
--enable-index-store
goes away once all the commands have the option group hidden. In my initial testing that's when I noticed that it would go away.
@swift-ci please smoke test |
Includes the new constructor that we need
@@ -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")), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
Sources/Commands/Options.swift
Outdated
return .on | ||
case .disableIndexStore: | ||
return .off | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this changes is a good one but we should do it in a separate PR
Sources/Commands/Options.swift
Outdated
} | ||
|
||
@Flag(help: "Enable or disable indexing-while-building feature") | ||
var indexStoreMode: StoreMode = .autoIndexStore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this changes is a good one but we should do it in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what fixes USAGE: init [<options>] --enable-index-store
preventing the index store from being printed out, should it still be another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please
@@ -12,7 +12,7 @@ import XCTest | |||
import Foundation | |||
|
|||
import TSCBasic | |||
import Commands | |||
@testable import Commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used?
Updated Toolchain |
swiftlang/swift/pull/37113 |
swiftlang/swift-driver#534 |
swiftlang/swift-driver#534 |
swiftlang/swift-driver#534 |
swiftlang/swift-driver#534 |
* Fix --help printout * What a fixed --help would look like All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help * Testable import, and throw InternalError * Updated all remaining commands * Bump Swift-Argument-Parser Includes the new constructor that we need * Reverted import of Commands * Reverted indexStore, to be implemented in separate pr Co-authored-by: Miguel Perez <[email protected]> (cherry picked from commit a52d4d8)
* Fix --help printout * What a fixed --help would look like All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help * Testable import, and throw InternalError * Updated all remaining commands * Bump Swift-Argument-Parser Includes the new constructor that we need * Reverted import of Commands * Reverted indexStore, to be implemented in separate pr Co-authored-by: Miguel Perez <[email protected]> (cherry picked from commit a52d4d8)
* Fix --help printout * What a fixed --help would look like All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help * Testable import, and throw InternalError * Updated all remaining commands * Bump Swift-Argument-Parser Includes the new constructor that we need * Reverted import of Commands * Reverted indexStore, to be implemented in separate pr Co-authored-by: Miguel Perez <[email protected]> (cherry picked from commit a52d4d8)
* Fix --help printout * What a fixed --help would look like All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help * Testable import, and throw InternalError * Updated all remaining commands * Bump Swift-Argument-Parser Includes the new constructor that we need * Reverted import of Commands * Reverted indexStore, to be implemented in separate pr Co-authored-by: Miguel Perez <[email protected]> (cherry picked from commit a52d4d8)
* Fix --help printout * What a fixed --help would look like All of our subcommands need fixing. This is a demo of what fixing all the commands would look like Also includes some fillings for `Options()` that didn't have any help * Testable import, and throw InternalError * Updated all remaining commands * Bump Swift-Argument-Parser Includes the new constructor that we need * Reverted import of Commands * Reverted indexStore, to be implemented in separate pr Co-authored-by: Miguel Perez <[email protected]> (cherry picked from commit a52d4d8) Co-authored-by: tomer doron <[email protected]>
Depends on this PR
Fixes
swift package init --help
to only show help forinit
This is a major UI improvement as it allows the user to focus on the help that is solely relevant to
init
, and not get overwhelmed with other options.rdar://76116106