Keep blank lines
It would be good to keep blank lines in the original file after the formatting has been applied, or at list to control this behaviour with a rule. Is it possible?
For example:
message Machine {
// Unique ID of the machine
string id = 1;
// Human readable name of the machine
string name = 2;
// Description of the machine
string description = 4;
// Machine image preview
string preview_image_url = 5;
}
Get formatted to the following, losing all blank line separation between the fields of the messages.
message Machine {
// Unique ID of the machine
string id = 1;
// Human readable name of the machine
string name = 2;
// Description of the machine
string description = 4;
// Machine image preview
string preview_image_url = 5;
}
What about if we add something like --keep-line-breaks or something like that?
@smaye81 @ronnylt
How to use format?
I execute ./prototool format test.proto and it did nothing.
Below is the content of test.proto
syntax = "proto3";
message Machine {
// Unique ID of the machine
string id = 1;
// Human readable name of the machine
string name = 2;
// Description of the machine
string description = 4;
// Machine image preview
string preview_image_url = 5;
}
```
Try this:
./prototool format -w --fix test.proto
See:
prototool format --help
So in looking at this, it will most likely be implemented slightly different. Keeping spaces will be too difficult due to the nature of how the proto files are traversed using the proto parser.
What we can do though is add a flag --newline or similar, which would simply add a newline between message fields so that they end up like:
message Example {
// This is a foo
string foo = 1;
// This is a bar
string bar = 2;
// This is a baz
string baz = 3;
}