You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michał Słomkowski 4ea6bbc1bd
Merge pull request #12 from denji/patch-1
6 years ago
test-files Add support for latin1 encoding of input files. #2 8 years ago
.gitignore Add support for latin1 encoding of input files. #2 8 years ago
LICENSE Initial commit 9 years ago
README.md Add support for variable marks ${ and }. Fixes #4 7 years ago
nginxfmt.py fix the multi_semicolon bug 6 years ago
test_nginxfmt.py fix the multi_semicolon bug 6 years ago

README.md

nginx config file formatter

This Python script formats nginx configuration files in consistent way, described below:

  • all lines are indented in uniform manner, with 4 spaces per level
  • neighbouring empty lines are collapsed to at most two empty lines
  • curly braces placement follows Java convention
  • whitespaces are collapsed, except in comments an quotation marks
  • whitespaces in variable designators are removed: ${ my_variable } is collapsed to ${my_variable}

Installation

Python 3.2 or later is needed to run this program. The simplest form of installation would be copying nginxfmt.py to your scripts directory.

You can also clone the repository and symlink the executable:

cd
git clone https://github.com/1connect/nginx-config-formatter.git
ln -s ~/nginx-config-formatter/nginxfmt.py ~/bin/nginxfmt.py

Usage

usage: nginxfmt.py [-h] [-v] [-b] config_files [config_files ...]

Script formats nginx configuration file.

positional arguments:
  config_files          configuration files to format

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         show formatted file names
  -b, --backup-original
                        backup original config file

Credits

Copyright 2016 Michał Słomkowski @ 1CONNECT. License: Apache 2.0.