Skip to content
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

Properly handle --stdin flag for printAST command #529

Merged
merged 2 commits into from
Jul 17, 2019

Conversation

shashachu
Copy link
Contributor

@@ -77,6 +77,6 @@ internal class PrintASTSubCommand : Runnable {

companion object {
internal const val COMMAND_NAME = "printAST"
private const val STDIN_FILE = "<stdin>"
private const val STDIN_FILE = "<text>"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the code explicitly uses this as a flag for stdin. we should probably move this into a constant somewhere.

Copy link
Collaborator

@Tapchicoma Tapchicoma Jul 16, 2019

Choose a reason for hiding this comment

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

Sorry, missed that as it is not a constant. Yes, you are right - would be better to add const val STDIN_FILE_NAME = "<stdin>" in https://github.com/pinterest/ktlint/blob/master/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt and use it here and in other places, so in the future it will not happen again.

Generally, I think, we should bring some integration test to command line module.

Copy link
Contributor Author

@shashachu shashachu Jul 16, 2019

Choose a reason for hiding this comment

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

@Tapchicoma updated with the constant Edit: and no need to apologize; I didn't notice in review either.

* Fixes pinterest#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable
@shashachu shashachu merged commit 579de38 into pinterest:master Jul 17, 2019
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jul 18, 2019
* Properly handle --stdin flag for printAST command

* Fixes pinterest#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable

* move stdin to constant
@shashachu shashachu deleted the printast branch August 2, 2019 22:16
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.

Can't printAST from stdin (Paths.get(fileName).parent must not be null)
2 participants