Skip to content

Commit

Permalink
Fill up readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
slomkowski committed Jun 16, 2016
1 parent ec596dd commit fe5c77d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
# THIS PROJECT IS WORK IN PROGRESS
# *nginx* config file formatter

# nginx config file formatter
This Python script formats *nginx* configuration files in consistent
way, described below:

Formats *nginx* configuration files.
* 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

## Installation

Requirements: Python 3+.
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

* todo command line args
* you can pass several files in command line
```
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

Expand Down
8 changes: 4 additions & 4 deletions nginxfmt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

"""add module description
"""
"""Script formats nginx configuration file."""

import argparse

Expand Down Expand Up @@ -96,11 +95,12 @@ def format_config_file(contents):

arg_parser.add_argument("-v", "--verbose", action="store_true", help="show formatted file names")
arg_parser.add_argument("-b", "--backup-original", action="store_true", help="backup original config file")
arg_parser.add_argument("config_file", type=argparse.FileType('r'), nargs='+')
arg_parser.add_argument("config_files", type=argparse.FileType('r'), nargs='+',
help="configuration files to format")

args = arg_parser.parse_args()

for config_file in args.config_file:
for config_file in args.config_files:
original_file_content = config_file.read()
config_file.close()

Expand Down

0 comments on commit fe5c77d

Please sign in to comment.