-
Notifications
You must be signed in to change notification settings - Fork 235
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
Gradually deprecate running swift-format without input paths; require '-' for stdin in the future #914
Conversation
d4c9aa0
to
6356aca
Compare
This would remove the ability to format/lint from Before breaking any of the current usage patterns, at a minimum I think we need to start allowing Then, after that release, we should revisit all of the default behaviors discussed in that thread holistically, so that we don't risk ending up in an intermediate stage if we were to make them arbitrarily or piecemeal. |
6356aca
to
d73a539
Compare
Oh, I missed that it's possible to format/lint without the |
d73a539
to
08f3f57
Compare
I prefer @allevato’s proposal to use
|
IDEs probably do this. Xcode does. So they will have to update to support this change. |
It think it’s not unreasonable to ask these clients to update. In only expect there to be a handful. |
08f3f57
to
5afe05e
Compare
swift format
command without arguments
Thank you all for taking the time to share your thoughts 🙇 |
d443f45
to
a2a0445
Compare
@@ -108,7 +108,7 @@ struct LintFormatOptions: ParsableArguments { | |||
var experimentalFeatures: [String] = [] | |||
|
|||
/// The list of paths to Swift source files that should be formatted or linted. | |||
@Argument(help: "Zero or more input filenames.") | |||
@Argument(help: "Zero or more input filenames. If no paths are provided, stdin input will be used (use `-`).") |
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.
@Argument(help: "Zero or more input filenames. If no paths are provided, stdin input will be used (use `-`).") | |
@Argument(help: "Zero or more input filenames. Use `-` for stdin.") |
No reason to explicitly document the "no paths" behavior if we're planning to deprecate it in the future; let's just document the happy path.
Running swift-format without input paths is deprecated and will be removed in the future. | ||
Please specify one of the following: | ||
- Use - to read from stdin (e.g., cat MyFile.swift | swift-format -) | ||
- Provide a directory path (e.g., swift format --recursive MyDirectory/) | ||
- Provide a specific Swift source file (e.g., swift format MyFile.swift) | ||
For more information, use the --help option. |
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.
Running swift-format without input paths is deprecated and will be removed in the future. | |
Please specify one of the following: | |
- Use - to read from stdin (e.g., cat MyFile.swift | swift-format -) | |
- Provide a directory path (e.g., swift format --recursive MyDirectory/) | |
- Provide a specific Swift source file (e.g., swift format MyFile.swift) | |
For more information, use the --help option. | |
Running swift-format without input paths is deprecated and will be removed in the future. | |
Please update your invocation to do either of the following: | |
- Pass `-` to read from stdin (e.g., `cat MyFile.swift | swift-format -`). | |
- Pass one or more paths to Swift source files or directories containing | |
Swift source files. When passing directories, make sure to include the | |
`--recursive` flag. | |
For more information, use the `--help` option. |
Just a little editorial cleanup.
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.
Thank you for your feedback!
a2a0445
to
0f1b558
Compare
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 for working on this! I know it's a lot smaller in scope than what you were originally looking to do, but staging this in gently will be important for our users.
… '-' for stdin in the future
0f1b558
to
3f041ed
Compare
As discussed in #871 and in this forum thread Default behavior of “swift format”, waiting for stdin when only the
swift format
command is entered causes significant confusion for new users.Although there were suggestions to provide a default behavior for convenience, I agree that it is not appropriate for a destructive change to take effect immediately.
However, at the very least, some guidance is needed to prevent the command from being perceived as hanging, so I've improved usability to output additional guidance when the user enters the
swift format
command alone.(same inswift format lint
).