Skip to content

Commit beda0b0

Browse files
committed
[README.md] Expand version range; include --help text ; [.github/workflows/python-package.yml] Bump versions ; expand version range ; [nginxctl/__main__.py] Fix help text on macOS ; [LICENSE-{APACHE,MIT}] Bump year range
1 parent f7e04b6 commit beda0b0

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

.github/workflows/python-package.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
15+
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', 3.11, 3.12, 3.13 ]
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1919
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v1
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip setuptools wheel
26-
pip install -r requirements.txt
26+
python -m pip install -r requirements.txt
2727
- name: Lint with flake8
2828
run: |
29-
pip install flake8
30-
flake8 . --count --select=$(printf '%s,' {A..Z}) --ignore='W503,E203' --show-source --max-complexity=13 --max-line-length=119 --statistics
29+
python -m pip install flake8
30+
flake8 . --count --select=$(printf '%s,' {A..Z}) --ignore='W503,E203' --show-source --max-complexity=13 --max-line-length=119 --statistics
3131
- name: Test with unittest
3232
run: |
33-
python setup.py test
33+
python setup.py test

LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2020 Samuel Marks (for Offscale.io)
190+
Copyright 2020–2025 Samuel Marks (for Offscale.io)
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2020 Samuel Marks (for Offscale.io)
1+
Copyright 2020–2025 Samuel Marks (for Offscale.io)
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
nginxctl
22
========
33
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT%20OR%20CC0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4-
![Python version range](https://img.shields.io/badge/python-2.7%20|%203.5%20|%203.6%20|%203.7%20|%203.8%20|3.9-blue.svg)
4+
![Python version range](https://img.shields.io/badge/python-2.7%20|%203.5%20|%203.6%20|%203.7%20|%203.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-blue.svg)
55
![Python lint & test](https://github.com/offscale/nginxctl/workflows/Python%20lint%20&%20test/badge.svg)
66
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
77
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
@@ -16,6 +16,43 @@ Commands for modifying and controlling nginx over the command-line.
1616

1717
pip install .
1818

19+
## Usage
20+
21+
usage: python -m nginxctl [-h] [--version] [--listen [LISTEN ...]]
22+
[--prefix PREFIX] [--temp_dir TEMP_DIR]
23+
[--nginx NGINX] [-b [BLOCK ...]] [-c CONFIG]
24+
[-{ [OPEN_PAREN ...]] [-} [CLOSE_PAREN ...]]
25+
{dry_run,emit,nginx,serve,upsert}
26+
27+
Commands for modifying and controlling nginx over the command-line.
28+
29+
positional arguments:
30+
{dry_run,emit,nginx,serve,upsert}
31+
serve, emit, nginx, or dry_run
32+
33+
options:
34+
-h, --help show this help message and exit
35+
--version show program's version number and exit
36+
--listen [LISTEN ...]
37+
Listen (e.g., port)
38+
--prefix PREFIX set prefix path, e.g., '/opt/homebrew/etc/nginx'
39+
--temp_dir TEMP_DIR serve uses this directory
40+
--nginx NGINX Path to nginx binary, defaults to first in PATH, i.e.,
41+
'/opt/homebrew/bin/nginx'
42+
-b [BLOCK ...], --block [BLOCK ...]
43+
Block, e.g., server or http
44+
-c CONFIG, --config CONFIG
45+
Name of file. Placed in prefix folder—e.g.,
46+
'/opt/homebrew/bin/nginx'—if not absolute. E.g.,
47+
nginx.conf
48+
-{ [OPEN_PAREN ...] Starting parentheses (raise hierarchy). Note:
49+
`-b`/`--block` does this also.
50+
-} [CLOSE_PAREN ...] Ending parentheses (lower hierarchy)
51+
52+
Example usage: python -m nginxctl -w '/tmp/wwwroot' -p 8080 -i '192.168.2.1'
53+
-w '/mnt/webroot' -p 9001 -i 'localhost' --path '/api' --proxy-pass
54+
'192.168.2.1/api'
55+
1956
## Examples
2057

2158
### Serve local directory and then stop server

nginxctl/__main__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ def _build_parser():
6767
default_nginx_usage = next(
6868
line for line in strings(default_nginx) if "set prefix path" in line
6969
).split()
70-
default_prefix, default_conf = tuple(
71-
l[:-1]
72-
for i, l in enumerate(default_nginx_usage)
73-
if i > 0 and "default" in default_nginx_usage[i - 1]
74-
)
70+
default_conf = next(filter(lambda s: s.endswith('nginx.conf)'), default_nginx_usage))[:-1]
71+
default_prefix = os.path.dirname(default_conf)
7572

7673
parser = ArgumentParser(
7774
prog="python -m {}".format(PythonPackageInfo().get_app_name()),

nginxctl/tests/test_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from boltons.iterutils import remap
1313
from pkg_resources import resource_filename
1414

15-
from nginxctl.helpers import del_keys_d, get_dict_by_key_val, update_directive
15+
from nginxctl.helpers import del_keys_d, get_dict_by_key_val, update_directive, pp
1616
from nginxctl.parser import parse_cli_config
1717
from nginxctl.pkg_utils import PythonPackageInfo
1818

@@ -45,6 +45,7 @@ def tearDown(self):
4545
rmtree(self.temp_dir)
4646

4747
def test_filter_map_block(self):
48+
pp(self.nginx_conf_parse)
4849
for config in self.nginx_conf_parse["config"]:
4950
self.assertEqual(config["status"], "ok")
5051

0 commit comments

Comments
 (0)