vasilevich / nginxbeautifier

Format and beautify nginx config files
https://nginxbeautifier.com
Apache License 2.0
167 stars 20 forks source link

Make "blank lines after curly" a configurable option #8

Closed erodewald closed 6 years ago

erodewald commented 6 years ago

Overview

I noticed that NEWLINEAFTERBRACET was just hardcoded to true, but I personally think it's strange looking. I do not commonly see this used, either. While this does change the default behavior (from true to false, effectively), I can change that back but I will need to have another go at the argument naming conventions.

Including --blank-lines makes it true, omitting it leaves it false. If flipped, I could see changing it to --no-blank-lines|-nbl.

Assumptions

No change in behavior here, but it is worth noting that using --blank-lines will add the blank lines after a curly bracket, but omitting the arg will not remove existing blank lines.

Examples

With --blank-lines | -bl

upstream rtsp-upstream {

  server 192.168.1.63:7447;
}

server {

  listen 443 ssl http2;
  listen 7443 ssl http2;
  server_name subd.domain.tv;
  access_log /var/log/nginx/subd.access.log;
  error_log /var/log/nginx/subd.error.log;
}

Omitting the --blank-lines argument


upstream rtsp-upstream {
  server 192.168.1.63:7447;
}

server {
  listen 443 ssl http2;
  listen 7443 ssl http2;
  server_name subd.domain.tv;
  access_log /var/log/nginx/subd.access.log;
  error_log /var/log/nginx/subd.error.log;
}

How to use it

Short arg Long arg What does it do
-bl --blank-lines If used, will insert a trailing blank line after an opening bracket
vasilevich commented 6 years ago

I find your suggestion acceptable thank you, I will pull it and upload to npm.

erodewald commented 6 years ago

This might actually be the fix for #4