Fill up readme.

pull/12/head
Michał Słomkowski 9 years ago
parent ec596dd7e8
commit fe5c77d2a5

@ -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 ## 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 ## 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 ## Credits

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""add module description """Script formats nginx configuration file."""
"""
import argparse import argparse
@ -96,11 +95,12 @@ if __name__ == "__main__":
arg_parser.add_argument("-v", "--verbose", action="store_true", help="show formatted file names") 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("-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() 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() original_file_content = config_file.read()
config_file.close() config_file.close()

Loading…
Cancel
Save