From fe5c77d2a503644bebee2caaa8b222c201c0603d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20S=C5=82omkowski?= Date: Thu, 16 Jun 2016 22:30:25 +0200 Subject: [PATCH] Fill up readme. --- README.md | 37 +++++++++++++++++++++++++++++++------ nginxfmt.py | 8 ++++---- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6ef6f4c..a092d1d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/nginxfmt.py b/nginxfmt.py index 1d8ac67..1bce3c5 100755 --- a/nginxfmt.py +++ b/nginxfmt.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -"""add module description -""" +"""Script formats nginx configuration file.""" 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("-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()