1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
Path-and-Address
================
Functions for command-line server tools used by humans.
Description
-----------
Path-and-address resolves ambiguities for command-line interface applications
with the following pattern:
```bash
$ your_app [<path>] [<address>]
```
The library applies [the principal of least surprise][pols] to command-line
interfaces.
Some examples:
```bash
$ your_app .
* Serving . on http://localhost:5000/
$ your_app 80
* Serving . on http://localhost:80/
$ your_app ./80
* Serving ./80 on http://localhost:5000/
$ your_app path/to/file
* Serving path/to/file on http://localhost:5000/
$ your_app 0.0.0.0
* Serving 0.0.0.0 on http://localhost:5000/
$ your_app . 0.0.0.0
* Serving . on http://0.0.0.0:5000/
$ your_app 0.0.0.0:8080
* Serving . on http://0.0.0.0:8080/
```
Usage
-----
Implement a CLI front-end in Python that exposes the above `[path] [address]`
pattern. Then call `resolve(path, address)`.
Example, using `sys.argv` directly:
```python
import sys
from path_and_pattern import resolve
path, address = resolve(*argv[1:])
```
More examples can be found in the "examples" directory.
Installation
------------
To install, simply:
```bash
$ pip install path-and-address
```
Or put it in your project's `requirements.txt`.
Contributing
------------
1. Check the open issues or open a new issue to start a discussion around
your feature idea or the bug you found
2. Fork the repository, make your changes, and add yourself to [Authors.md][]
3. Send a pull request
[pols]: http://en.wikipedia.org/wiki/Principle_of_least_astonishment
[authors.md]: ./AUTHORS.md
|